How to know path name from whos called
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
How to know path name from whos called
I have following trouble (I will give example):
Program1.prg (this is HMG IDE which call a Editor)
Function Main()
Local cDir:="\folder1" // this is not fixed. Always changing folder according each project placed
Local cFile:="File1.prg" // this is not fixed too, according project files
Local cApp:="c:\folder2\Program2.exe" // this is fixed
ChangeDir(cDir)
cCommand:=cApp+" "+cFile
MyRun(cCommand)
Return Nil
Program2.prg (this app always will be at c:\folder2 folder)
Function Main(cFile)
MsgInfo( cFile ) // ok showing right file name
MsgInfo( here I need to Get Folder name of that cFile. But how I do this ? )
Return Nil
All my tries was using GetCurrentFolder() and GetStartUpFolder() but always returning "c:\folder2" and I need to know which folder Program1 was positioned.
Any body to help me please ?
Program1.prg (this is HMG IDE which call a Editor)
Function Main()
Local cDir:="\folder1" // this is not fixed. Always changing folder according each project placed
Local cFile:="File1.prg" // this is not fixed too, according project files
Local cApp:="c:\folder2\Program2.exe" // this is fixed
ChangeDir(cDir)
cCommand:=cApp+" "+cFile
MyRun(cCommand)
Return Nil
Program2.prg (this app always will be at c:\folder2 folder)
Function Main(cFile)
MsgInfo( cFile ) // ok showing right file name
MsgInfo( here I need to Get Folder name of that cFile. But how I do this ? )
Return Nil
All my tries was using GetCurrentFolder() and GetStartUpFolder() but always returning "c:\folder2" and I need to know which folder Program1 was positioned.
Any body to help me please ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to know path name from whos called
Does the cFile have the full path?Program2.prg (this app always will be at c:\folder2 folder)
Function Main(cFile)
MsgInfo( cFile ) // ok showing right file name
MsgInfo( here I need to Get Folder name of that cFile. But how I do this ? )
Return Nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
How to know path name from whos called
Thanks my friend for your interest.
No, this is only file name. It´s an argument received from HMG IDE when call Module Editor at Preferences in Tools IDE menu.
I wish to make some improvements using external programs thru IDE when call source's editor. In this my test of Demo.exe I will also call Notepad++ (this is already working) but before I need to know from which folder had been called in Program2.
HMG IDE pass only file name when user clicks on PRG name at Project Browser of IDE.
No, this is only file name. It´s an argument received from HMG IDE when call Module Editor at Preferences in Tools IDE menu.
I wish to make some improvements using external programs thru IDE when call source's editor. In this my test of Demo.exe I will also call Notepad++ (this is already working) but before I need to know from which folder had been called in Program2.
HMG IDE pass only file name when user clicks on PRG name at Project Browser of IDE.
Last edited by Pablo César on Tue Nov 27, 2012 2:12 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: How to know path name from whos called
Hi Pablo
I'm not sure that right understood you question
But I guess TrueName() function may help you.
Regards
I'm not sure that right understood you question
But I guess TrueName() function may help you.
Regards
Viva INTERNATIONAL HMG 
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: How to know path name from whos called
Ohhh man ! You hit it !!! Right, that's it what I was looking for. This TrueName returning with path, then It will be easy to know from where.esgici wrote:But I guess TrueName() function may help you.
THANK YOU amigo Esgici and Rathinagiri for your attention !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to know path name from whos called
Whenever IDE is started and we click the open project button, the last project folder is displayed irrespective of the HMG/IDE version. That means that IDE stores this folder name somewhere common in registry/ini file. I don't know where!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: How to know path name from whos called
Yeap, thank for you tip. I understood your idea, GetFile() in the IDE source should have I Default path given by OS. I will look in MSDN if I find something about.rathinagiri wrote:Whenever IDE is started and we click the open project button, the last project folder is displayed irrespective of the HMG/IDE version. That means that IDE stores this folder name somewhere common in registry/ini file. I don't know where!
I make some implement in Claudio's View_Build_Log app just to push those info. Because, View_Build_Log shows a list of Projects from Recent Files but needs user click to PRG file thru Windows Explorer for append that list. Otherwise, not by opening thru IDE all project are shown.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
-
klauskugel
- Posts: 90
- Joined: Tue Oct 09, 2012 2:28 pm
Re: How to know path name from whos called
Hi Pablo,
could it be that you're looking for
these Functions
winnetwk.h // mingw
...
DWORD APIENTRY WNetGetUniversalNameA(LPCSTR,DWORD,PVOID,PDWORD);
DWORD APIENTRY WNetGetUniversalNameW(LPCWSTR,DWORD,PVOID,PDWORD);
If that's wrong,
why not search for the ini-File
GetPrivateProfileStringA kernel32.dll
WritePrivateProfileStringA kernel32.dll
So you can read/write any private ini's like hmg.ini or something,
to store private stuff.
Greetings klauskugel
Hope it helped
could it be that you're looking for
these Functions
winnetwk.h // mingw
...
DWORD APIENTRY WNetGetUniversalNameA(LPCSTR,DWORD,PVOID,PDWORD);
DWORD APIENTRY WNetGetUniversalNameW(LPCWSTR,DWORD,PVOID,PDWORD);
If that's wrong,
why not search for the ini-File
GetPrivateProfileStringA kernel32.dll
WritePrivateProfileStringA kernel32.dll
So you can read/write any private ini's like hmg.ini or something,
to store private stuff.
Greetings klauskugel
Hope it helped
-
klauskugel
- Posts: 90
- Joined: Tue Oct 09, 2012 2:28 pm
Re: How to know path name from whos called
Hi Pablo,
found another function which returns the Fullpath
DWORD GetFullPathName(LPCTSTR lpFileName,DWORD nBufferLength,LPTSTR lpBuffer,LPTSTR *lpFilePart);
http://winapi.freetechsecrets.com/win32 ... thName.htm
Function Main()
Local cDir:="\folder1" // this is not fixed. Always changing folder according each project placed
Local cFile:="File1.prg" // this is not fixed too, according project files
Local cApp:="c:\folder2\Program2.exe" // this is fixed
ChangeDir(cDir)
Why not at 1st set the Set the DriveLetter first?
BOOL SetCurrentDirectory( LPCTSTR lpPathName );
Some of these might hit it.
If not - hmmm.,
we go on searching.
Happy HMGing
klauskugel
found another function which returns the Fullpath
DWORD GetFullPathName(LPCTSTR lpFileName,DWORD nBufferLength,LPTSTR lpBuffer,LPTSTR *lpFilePart);
http://winapi.freetechsecrets.com/win32 ... thName.htm
Function Main()
Local cDir:="\folder1" // this is not fixed. Always changing folder according each project placed
Local cFile:="File1.prg" // this is not fixed too, according project files
Local cApp:="c:\folder2\Program2.exe" // this is fixed
ChangeDir(cDir)
Why not at 1st set the Set the DriveLetter first?
BOOL SetCurrentDirectory( LPCTSTR lpPathName );
Some of these might hit it.
If not - hmmm.,
Happy HMGing
klauskugel
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
How to know path name from whos called
You are right klauskugel, DriveLetter may contain a drive designator and a path for ChangeDir() function.klauskugel wrote: ...
Local cDir:="\folder1" // this is not fixed. Always changing folder according each project placed
Why not at 1st set the Set the DriveLetter first?
Some of these might hit it.
I thank you very much for your indications. But this have already solutioned when Esgici has indicated TruName() function. All codes that I posted was just for referance, I was trying to explain the problem. What Mr. Rathinagiri appointed was about last path was accessed when you call GetFile() which it´s means that SO (or properly: Method System IO) keep in some where (we do not know where) to get this information. And this is very interesting now, because I trying to implement a way to keep last project files are accessed for historical proposes. But I probably will take projects files accessed and will store in DBF. Will be more simple and flexible too.
By the other hand, I have another problematic question. I need to know the handle Window of HMG IDE when is open. Upto here, no problem. This is very simple to find by Title name which starts "HMG IDE (c)..." but the problem is when many projects are open and can not know which IDE's window is right for handling. By title with project name would makes easier to identify when you have many IDE's section open. This is really hard to get a solution. I have probably a way, but I not sure. As I said, IDE can call Notepad++ editor when you double click at PRG file in "Project Browser" of IDE. But if you change in preference Notepad++ with your own program, IDE will call it. So I think can be possible to get a handle is calling (in this case: IDE's handle) but I not sure of this.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein