I just wrote a prog to get the Version on Windows running. But i'm having trouble with the wsprintf at the bottom. Can anyone tell me why it doesn't return the Windows Version? I've tried a few things, but i always look over the little things. This is pretty simple...maybe it should be in the begginers section...? Thanks! Nok. ;-------------program-starts-here--------------------------- .386 .model flat, stdcall option casemap:none ; case sensitive include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\wsock32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\wsock32.lib includelib \masm32\lib\masm32.lib .data ninefive db '95',0 nineeight db '98',0 nt db 'NT%i(%lu)',0 pass db '1',0 Caption db 'Windows Info:',0 Message db 'You are using Windows%lu',0 .data? vinfo OSVERSIONINFO<> buffer db 256 dup(?) .code start: GetVersion PROC mov vinfo.dwOSVersionInfoSize, sizeof OSVERSIONINFO invoke GetVersionEx, offset vinfo cmp vinfo.dwPlatformId, VER_PLATFORM_WIN32_NT jne win9x invoke wsprintf, addr buffer, offset nt, vinfo.dwMajorVersion, vinfo.dwBuildNumber jmp GotVersion win9x: cmp vinfo.dwMinorVersion, 0 jne win98 invoke lstrcpy, addr buffer, offset ninefive jmp GotVersion win98: invoke lstrcpy, addr buffer, offset nineeight invoke atodw, offset pass cmp eax, 1 je GotVersion GotVersion: invoke wsprintf,addr buffer,offset Message,eax invoke MessageBox,NULL,addr buffer,addr Caption,MB_OK+MB_ICONINFORMATION ret GetVersion ENDP end start
If I understand your code correctly, you assume that at GotVersion, eax points to the windows version text. But this is not true because for winnt, you use wsprintf, which returns the number of chars in the output string, for win9x lstrcpy returns the pointer correctly, but atodw doesn't return a pointer either. Then there is
The %lu should be %s, because you are inserting text in stead of a dword number (%lu). Finally, you can't use the output buffer as an input at the same time. In the final wsprintf and messagebox, change the output pointer to buffer2 or something. Thomas
Message db 'You are using Windows%lu',0
The wsprintf, just before the MessageBox, wipes out all the previous work you did in putting data into buffer. The buffer can't be treated like a file; where every time you write to a file, it grows the data.