by Michael Calkins (Login MCalkins)
ASM Forum

I had tried using a C header to get around the problem I was having (on the main forum), but I couldn't make it work. I guess I'll wait for the next update to try again with QB64.

Anyway, here is a C program.

I'm not sure of the best way of initializing Unicode strings without null termination. I do it here by using a sequence of hex word values. I tried using individual letters in quotes, but it didn't work.

I'm not sure why I need to cast &Filename as LPWSTR, since LPWSTR means a pointer to a WCHAR ("typedef WCHAR *LPWSTR;"), and Filename is a WCHAR array...

I used the windows.h header partly for convenience, and partly because I would think QB64 uses it. It shouldn't be necessary, though. It should be possible, but maybe not preferable, to just include custom prototypes for the API functions without using the Windows header files. You wouldn't have HANDLE, you would have void * (although I would probably just use unsigned long int). You wouldn't have DWORD, you would have unsigned long int. You wouldn't have WCHAR, you would have unsigned short int. There sure are a lot of typedefs in the windows header files. I guess it's more convenient just to use the Windows header files, and Microsoft's myriads of types.

I'm not sure if the compiler considers a new type to be compatible to the type it was derived from using typedef.



#include <windows.h>

HANDLE stdout;
DWORD trash;
WCHAR Filename[0x200];
WCHAR msg0[0x13]={0x75,0x6e,0x69,0x63,0x6f,0x64,0x65,0x20,0x66,0x69,0x6c,0x65,0x6e,0x61,0x6d,0x65,0x3a,0xd,0xa};
WCHAR msg1[0x14]={0x74,0x72,0x79,0x20,0x61,0x20,0x6c,0x61,0x72,0x67,0x65,0x72,0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x2e};
WCHAR crlf[0x2]={0xd,0xa};

int main()

stdout = GetStdHandle(0xfffffff5);

l = GetModuleFileNameW(0,(LPWSTR) &Filename,0x200);

if (l)
WriteConsoleW(stdout, &msg0, 0x13, &trash, 0);
WriteConsoleW(stdout, &Filename, l, &trash, 0);
WriteConsoleW(stdout, &crlf, 0x2, &trash, 0);
WriteConsoleW(stdout, &msg1, 0x16, &trash, 0);
return 0;

Posted on Aug 31, 2011, 3:30 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
I see the bugComputerGhost on Sep 14
 Interesting.Michael Calkins on Sep 15
  Re: Interesting.ComputerGhost on Sep 15
   Re: Interesting.Michael Calkins on Sep 15
    Re: InterestingComputerGhost on Sep 15
     Re: InterestingMichael Calkins on Sep 16
    * const data goes in .rdata, not .textMichael Calkins on Aug 22

 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement