Jump to content
Mike Torrettinni

Get Parent process Current directory

Recommended Posts

Guest

Wow! This was a long one, and i do not feel i have the time to sift. But i do have one comment (admittedly w/o knowing your actual problem and a sleuth of other parameters).

 

The "Current directory" thingy from back when is one of the "thingies" that has bitten me most during 35 years of production.

Some 10-15 years ago i have become very very very fastidious with NEVER using relative paths in Win32 desktop (VCL) and VCL-based services.

I simply do not do that. The strategy is borrowed from how i handle Facebook et.al. I'm sure there is an expression or a concept for that strategy, just do not have the fancy words.

Edited by Guest
linguistic details

Share this post


Link to post

OK, let me try with example, lets look at Photoshop. Imagine it can be setup so each currently opened file you work on has it's own temp/permanent folder that contains scratch files, history, backup files... basically anything related to your .psd file.

And you have a plugin/external tool that extends Photoshop features, based on all those files (perhaps you can look at the history, and pick and choose from it; perhaps there are files that contain brushes... anything that Photoshop doesn't make available on it's own).

 

And Photoshop has an option to send a current working filename to your external tool and it only sends filename, but not the current working folder that has all the other files. The information about that folder is available for users to setup in Photoshop, so they know exactly where it is, but your tool doesn't. So, you can't really go to Adobe and ask them to modify their script to pass all the info you need, to make it easier for your tool.

 

And the way Photoshop 'calls' your external tool is with a cmd from the current working folder of the current opened file. And this is the info your tool needs to work with to be useful.

 

18 minutes ago, Dany Marmur said:

Wow! This was a long one, and i do not feel i have the time to sift

Yes, it took me a while to realize that Parent process is not persistent and even if it was, it's not easy to get it's current working dir, because the OS doesn't have this info just readily available.

Share this post


Link to post
2 hours ago, Mike Torrettinni said:

Perhaps I don't know that it's possible, but can you identify what was the current directory that your project was called from? Please share the code.

It's almost as if this thread didn't happen! What have we been talking about before now??? 

Share this post


Link to post
Guest

@Mike Torrettinni, k, so there's a real use-case. Cool.

Integration with Photoshop (a multiplatform suite that actually has it's own platform on top, or below, that) should be done using the abilities and preferred integration strategy that Adobe suggest/documents/implement for that (Photoshop). IMHO you will run in to "thingies" for eternality. Once again, my meta-KISS-head is rearing.

Share this post


Link to post
1 minute ago, Dany Marmur said:

@Mike Torrettinni, k, so there's a real use-case. Cool.

Integration with Photoshop (a multiplatform suite that actually has it's own platform on top, or below, that) should be done using the abilities and preferred integration strategy that Adobe suggest/documents/implement for that (Photoshop). IMHO you will run in to "thingies" for eternality. Once again, my meta-KISS-head is rearing.

Photoshop was just an example of impossibility for me to ask/force all these big companies to customize their tools to fit the needs of my tool. Just because they don't make it easy, doesn't mean it's not possible.

Like I said, the user manual setup works just fine, the value of the tool is well worth even if the manual change is needed a few times a day - but it's annoying and now I'm investigating this option.

Share this post


Link to post
Guest

Short "anectdote" about when integration with multi-platform softwrare.

 

Long time ago i implemented integration between an VCL app and GroupWise.

My competitors simply did not deliver. They could not do it.

Me, with my single-developer-head never gave up and got the thing going.

But all the small "showstoppers" that ensued because GroupWise were managed/updated/integrated through hooops, that almost killed my business.

So... i was the stupid one to put effort into something that strategically was BAD.

My competitors, the story do not tell, maybe they just gave up. OR they might have had someone do some research and conclude - that will be a maintenance hell.

Thankfully my client ditched GroupWise at a pertinent time in history.

 

Point being.... if you do not have a "business" that Adobe cares about, you can code and develop and they will break it because you invented ways that they do not officially keep working between versions and platforms.

 

Sorry for being OT!

Share this post


Link to post
Guest

@Mike Torrettinni, we write at the exact same time. But it is clear that your understanding of these kind of endeavours are on par!

If you are writing an "internal tool" you can keep you eyes on it.

If you are writing software for a client with offices from Stockholm, Balkan, via the Gaza strip and down around to Burma, well, support is not that simple. Cool! Good luck!

Share this post


Link to post
17 hours ago, Mike Torrettinni said:

OK, let me try with example, lets look at Photoshop. Imagine it can be setup so each currently opened file you work on has it's own temp/permanent folder that contains scratch files, history, backup files... basically anything related to your .psd file.

And you have a plugin/external tool that extends Photoshop features, based on all those files (perhaps you can look at the history, and pick and choose from it; perhaps there are files that contain brushes... anything that Photoshop doesn't make available on it's own).

 

And Photoshop has an option to send a current working filename to your external tool and it only sends filename, but not the current working folder that has all the other files. The information about that folder is available for users to setup in Photoshop, so they know exactly where it is, but your tool doesn't. So, you can't really go to Adobe and ask them to modify their script to pass all the info you need, to make it easier for your tool.

 

And the way Photoshop 'calls' your external tool is with a cmd from the current working folder of the current opened file. And this is the info your tool needs to work with to be useful.

"Current directory" is a per-process property that could be set to anything when a process is launched and later changed to anything by the process itself. By default (if not set by the CreateProcess parameters) it is inherited by launched processes.

So. If your "Photoshop" really changes CDir to the path of currently opened file (which is weird IMHO) and doesn't specify CDir in the CreateProcess call, you can just invoke GetCurrentDirectory and chill.

If it doesn't, all you've got to do is to suppose things with non-100% probability and dive into the abyss of dirty hacks.

F.i., you can list handles of files opened by the parent process and find the full path but this requires elevated privileges and there's a chance that two files with the same name are opened at the same time.

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×