tgoerg
tgoerg

Reputation: 143

Error with call of WinApi GetVersionExA function: Error A2114 INVOKE argument type mismatch : argument : 1

I need to call the GetVersionExA function from the program written on masm. it accepts a single parameter lpVersionInformation of the type LPOSVERSIONINFOA. Where LPOSVERSIONINFOA as i suppose is the instance of _OSVERSIONINFOA struct. So i wrote this simple program but got following error:

Error   A2114   INVOKE argument type mismatch : argument : 1 
                                                            main.asm    24

I do not know what is wrong and how to fix it.

.586
    .model flat, STDCALL
    option casemap :none
    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\Advapi32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\Advapi32.lib
    .data
    params OSVERSIONINFOA  <>
    buf db 100 dup(?),0
    titl1 db '№ 5 ', 0
    ifmt db "Info = %d %d %d %d %d %c",0dh,0ah,0ah,0
    .code
    Start:
    invoke GetVersionEx, params ; <================================ 24

    invoke wsprintf,ADDR buf,ADDR ifmt,params.dwOSVersionInfoSize,params.dwMajorVersion ,params.dwMinorVersion ,params.dwBuildNumber ,params.dwPlatformId ,params.szCSDVersion
    invoke MessageBox, NULL, ADDR buf, ADDR titl1, MB_OK
    invoke ExitProcess, 0 
    end Start

Upvotes: 0

Views: 424

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595837

LPOSVERSIONINFOA is a pointer to an OSVERSIONINFOA. So, just as wsprintf() takes the address of an allocated char[] array to write into for returning its output string, GetVersionEx() takes the address of an allocated OSVERSIONINFOA to write into for returning its version data.

Also, you need to set the OSVERSIONINFOA.dwOSVersionInfoSize field before calling GetVersonEx(), so it knows whether you are passing it the address of an instance of OSVERSIONINFOA or OSVERSIONINFOEXA (which have different sizes and fields).

Upvotes: 2

Related Questions