views:

62

answers:

1

I have a .CAB file that runs as part of an installer process on a Windows CE box. The CAB is written in C++.

The CAB file is ran twice as part of an upgrade process but in different locations at different times. How can I find out what directory the .CAB file is being executed from (executing directory) using C++ only?

Thanks

+4  A: 

If by "C++ only" you mean without using Windows API, I don't think the standard library has a function to do that.

If you can call a Win32 API, you just have to call GetModuleFileName() with NULL as the first parameter, and you will get the path of the current executable.

Now, the problem is: we you run the .CAB, what is the executable? The install DLL extracted from the .CAB, or the shell component that is running the .CAB?

You can also try GetCommandLine(), as the first entry should be the executable path/name (it is actually the string passed to CreateProcess(), so you can't be 100% sure about it).

Lorenzo
I have access to winbase so this should work, I'll try it now
Chris
This unfortunately only shows the path to wceload.exe that loads executes the cabfile and not the cabfile location itself :(
Chris
OK, so try with GetCommandLine(), hopefully you will see the path of the CAB as the parameter of wceload...
Lorenzo