Executable folder location
Posted: Fri Feb 17, 2023 2:10 pm
This may be more of a Windows question but it involves PureBasic so here goes:
I wrote a shell replacement in PureBasic for a Point of Sale register which runs on Windows 10. When the register boots up, instead of running Explorer.exe, which is the normal Windows shell, I made a registry entry that points to my shell program to run instead:
HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell\POSShell.exe
POSShell.exe resides in C:\Shell which is included in the environment variable %PATH% so it can be launched from anywhere.
This works fine except my shell program reads an .INI file located in the same directory as the shell executable. When I boot the machine and my shell program starts up, it is unable to see or find the .INI file.
After some experimentation, I inserted this into my code:
Debug (GetCurrentDirectory())
The debug message returns: C:\Windows\System32
Should it not return: C:\Shell ?
If I run POSShell.exe after letting Windows boot regularly to Explorer then it finds and reads the .INI file just fine and the debug message returns C:\Shell.
Now, to make matters worse, I have a shell that I wrote previously in AutoIt that is setup identically as above and when launched with the registry pointing to it, executes perfectly and reads the .INI file just fine.
If I hard code the path of the .INI file in my program it works just fine but I don't want to do that.
As I say, this may not be a direct PureBasic problem but I am stumped and would welcome any input you could give. I can post my code if that will help. Thank you.
I wrote a shell replacement in PureBasic for a Point of Sale register which runs on Windows 10. When the register boots up, instead of running Explorer.exe, which is the normal Windows shell, I made a registry entry that points to my shell program to run instead:
HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell\POSShell.exe
POSShell.exe resides in C:\Shell which is included in the environment variable %PATH% so it can be launched from anywhere.
This works fine except my shell program reads an .INI file located in the same directory as the shell executable. When I boot the machine and my shell program starts up, it is unable to see or find the .INI file.
After some experimentation, I inserted this into my code:
Debug (GetCurrentDirectory())
The debug message returns: C:\Windows\System32
Should it not return: C:\Shell ?
If I run POSShell.exe after letting Windows boot regularly to Explorer then it finds and reads the .INI file just fine and the debug message returns C:\Shell.
Now, to make matters worse, I have a shell that I wrote previously in AutoIt that is setup identically as above and when launched with the registry pointing to it, executes perfectly and reads the .INI file just fine.
If I hard code the path of the .INI file in my program it works just fine but I don't want to do that.
As I say, this may not be a direct PureBasic problem but I am stumped and would welcome any input you could give. I can post my code if that will help. Thank you.