Mike Torrettinni
Members-
Content Count
1509 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Mike Torrettinni
-
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
OK, let me try to explain: I have a project that is run by different tools and it has limited info that it can receive (well, limited info/parameters are available from the calling tools - the tools I don't control), and those tools don't send their starting directory, although I need it in 100% cases. So, my project needs to have manually adjusted a setting that tells what the what the calling tool is and the starting point/directory. And based on that info my project behaves as it should. And users need to set this manually. In many cases they set it once and forget about it. But there are cases where they need to 'switch' between multiple start locations, multiple times a day - annoying, but necessary. So I have 2 options to improve this, to some extent: there is limited option where I can have a batch to run between the tool and before my project gets called (so the tool actually run my the batch file), which in theory could be used to get the start directory and pass it to my project. But this is not 100% in all cases, well this is also still being researched and in testing mode, because not all tools call my project in the same way. But when I was looking at how these tools behave with Process monitor, I saw that the Current directory info was available for every instance of a Parent process. Testing with a few most commonly used tools, the Parent task was always opened, while running my project. And I was hoping I can get the same info within my project. And here we are now, knowing that I can't rely on a fact that the parent process will always be opened, for my project to query it's info. So, now back to trying to make it work with batch file in between and see what 'limited or unlimited' options I have there. I thought it would be pointless to put all this into the original post. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
So, long story short, David was right, I did find a tool that closes it's process right after it calls my project. So, if I want to have broad solution, I have to take this into account. Even though this tool is rarely used, I can't rely on the fact other tools that keep the process open, will not change their implementation in the future. OK, research done. This is not the way to do it: can't rely on Current directory of the Parent process. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
Thanks, I think I don't want to go near this. I have no idea how this affects the running process, if anti-malware could catch the action and alert users... I don't even want to think how to defend the action, this definitely feels like going rogue on my customers 🙂 -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
Right now I have a workaround, a solution that works, but it requires manual work by users and in some cases (big customers) they need to do this manual work multiple times a day - they know the 'current directory'. I'm trying to avoid this and automate without their interaction. One way is to have that interceptor/bridge batch that can pass the parameter, or perhaps I can find by looking at Parent's info. Like I said, the process stays opened, until my process is done. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
It could be that will be the case in some situations, but currently the process waits until my project closes. And if it does, I believe the solution is to see if the process with same PID has been created after my process (so the original parent exited and same PID might be assigned to new process). Yes, in a way I am/can be in charge, but I'm trying to figure out a way to do this without this, so it's more general solution. Last night I noticed that Process monitor can get the Current directory, so overnight I tried to find a way to do it on my own. So, as hours progressed I have more info, and now I see that this could be a tricky thing. But I'm not done looking into it, yet. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
Ok, makes sense. I'm not against the need for my project to run as admin, if necessary. But as I tested a script that might give the correct info, it fails to use ReadProcessMemory (after NtQueryInformationProcess(handle, ProcessBasicInformation...) ) on the selected parent process, with or without Delphi running as Admin. For some other processes I can see PWD=c:\... info, which I think is what I'm looking for (but not 100%), just not for the processes I need. Seems like I'm close, but I've never done anything like reading other processes memory, so it's a little of guesswork. I thought someone already has done something like this, in Delphi, of course. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
It has a lot of info, like ExecutablePath, but not Current directory. I already have a way to get Parent's executable path. Unless, I'm not seeing something obvious, this can't help me. -
Get Parent process Current directory
Mike Torrettinni replied to Mike Torrettinni's topic in Windows API
Yes, seems like could be tricky, not reliable. If I understand correctly this answer, then is not documented and I think translating this into possible Delphi code is out of my league: https://stackoverflow.com/a/16142791 "As other pointed out, this is completely undocumented, but here is a piece of code that does it (as of today, it seems to work). Of course, it needs to run as admin. Note it can work for any process bitness, 32-bit or 64-bit (some processess may report an access denied, even running as admin), with any compilation target (x86 or x64). It also is capable of reading the command line. Use at your own risk!" -
I have a screen with multiple tree views, with different type of content, so it's hard to design ribbon toolbar for all actions, based on active treeview. Does anybody know of 3rd party context menu that works like in Word when you select text and the context menu just pops-up and offer most common actions (font change...)? I would like the menu to appear as soon as mouse gets into the treeview (not on right click) and perhaps more greyed out look until user hovers over it, to show intent to use it: Of course not the same actions as in Word, I would have my own custom icons. I've seen similar options in some other software, but don't remember where, but it was pretty useful. I would prefer ready made solution, not really something I need to design on my own. Any suggestions are welcome! Thanks.
-
Thanks, will have a look!
-
hm, maybe I don't need transparency, maybe just grayed out, like disabled...
-
thanks, I didn't know this is the control, mini toolbar! Seems like it could be what I need, except is missing the transparency look...
-
Yes, you have a point there, but ready made context menu controls can handle icons, shortcuts, selection, submenus... that's seems like overkill to develop from scratch.
-
Anybody changing FileVersion directly in dproj file?
Mike Torrettinni replied to Mike Torrettinni's topic in General Help
Thanks for the idea, I was doing this manually, now automated! -
Anybody changing FileVersion directly in dproj file?
Mike Torrettinni replied to Mike Torrettinni's topic in General Help
I never noticed corrupt .dproj file, but .dpr at least several times a year. Quick check in source control and restore, if needed. I've been running builds with this new TDprojParser and all seems to work pretty good! -
Anybody changing FileVersion directly in dproj file?
Mike Torrettinni replied to Mike Torrettinni's topic in General Help
Aha, it creates .rc file. Why do you put it in .dpr, to keep it with the project so you know what version it built, right? -
Anybody changing FileVersion directly in dproj file?
Mike Torrettinni replied to Mike Torrettinni's topic in General Help
I'm not sure what you are showing here... I'm not familiar with this syntax. Would you mind expanding on this? -
Anybody changing FileVersion directly in dproj file?
Mike Torrettinni replied to Mike Torrettinni's topic in General Help
Thanks, but that's overkill for my needs. -
Why compiler allows this difference in declaration?
Mike Torrettinni posted a topic in RTL and Delphi Object Pascal
Is this a compiler flaw in Delphi 10.2.3: it allows this: procedure Run(const aText: string = ''); implementation procedure Run(const aText: string); begin end; but not this (error E2037): procedure Run(const aText: string); implementation procedure Run(const aText: string = ''); begin end; Shouldn't it complain the same in both cases?: E2037 Declaration of 'Run' differs from previous declaration -
Why compiler allows this difference in declaration?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Shame they didn't adopt this and implement everywhere. Perhaps we should request they add 'mandatory' flag to feature requests 🙂 -
Why compiler allows this difference in declaration?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
This is interesting, it seems to allow even more than 1 parameter: procedure Run(const aText:string = ''; const aText2: string = ''; const aText3: string = ''); And code completion recognizes parameters: -
Why compiler allows this difference in declaration?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Make sense. I didn't see it that way, I just thought it simply compares declarations. But it make sense now why also overload override forward inline keywords behave the same. Thanks! -
half price 50% off on all editions of the HelpNDoc help authoring tool
Mike Torrettinni replied to HelpNDoc's topic in Delphi Third-Party
I only need CHM and HTML format, so I will be able to import chm file, ok. Any main advantage or disadvantage of your tool over h&m (only regarding chm and html format)? -
half price 50% off on all editions of the HelpNDoc help authoring tool
Mike Torrettinni replied to HelpNDoc's topic in Delphi Third-Party
@HelpNDoc Could this replace Help and Manual? Can I import the project from that tool to yours? -
Delphi Daily WTF / Antipattern / Stupid code thread
Mike Torrettinni replied to Tommi Prami's topic in RTL and Delphi Object Pascal
I did find this in some of the open source projects, I guess nobody complained, yet.