Can someone tell me please, that is the best way to find the drive (letter) of my runnig programm! Is there an API or must I analyse the command line? thanks
Posted on 2001-05-31 18:16:00 by hans Wurst
I recommend you to use the GetModuleFileName api. The first letter of your buffer is the drive where your program is stored. DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // file name of module DWORD nSize // size of buffer ); I can write a little example if you want. Hope this helps. Happy coding.
Posted on 2001-06-01 01:49:00 by Readiosys
Thanks for the fast replay! It works fine! push 256 push offset lpFilename push NULL call GetModuleFileName mov eax, offset lpFilename mov eax, mov , al mov , ah Or did you have an better idea how to move ax ('C:') in lpDir?
Posted on 2001-06-01 05:44:00 by hansWurst
I was happy to help you. Try to push 2 instead of 256... I think you will have the two first characters of the program path in your destination buffer... so, it will save some instructions... space, and run time :). Happy coding.
Posted on 2001-06-01 10:19:00 by Readiosys
Thanks! It works with three cause one letter that the api sends back is 00h for end of line. But this one works really good. push 3 push offset lpFilename push NULL call GetModuleFileName mov eax, offset lpFilename mov eax, push ax pop word ptr
Posted on 2001-06-01 12:17:00 by hansWurst