views:

38

answers:

1

Hi!

I have the following code: http://privatepaste.com/8364a2a7b8/12345

But it only writes "c" (supposedly, conversion to LPBYTE leaves one byte only).

What's the proper way to handle GetModuleFileName and registry edit?

+1  A: 
strlen((char*)szPath2)+1

This is most likely where your problem is. I bet your program is compiled in UNICODE mode. strlen only works properly for ASCII strings. (The fact that you're having to cast from TCHAR to char is a big hint that something isn't right.)

To keep consistent with the usage of TCHAR and such, you should probably use _tcslen instead.

TheUndeadFish