call-convention 74 is cc74

I have a subprogram that uses the functions
            call-convention 66 is dynamicWINAPI
            call-convention 74 is cc74

but to include it in .NET project has an error

            call cc74 'FindFirstFileA'
                by using reference findFileName
                      by reference WIN32-FIND-DATA
                returning fileSearchHandle

How to solve this problem?

  • To which error are you referring?

    You may be getting a warning from the compiler stating that the call will be treated as dynamic and that is normal.

    When you are calling a Windows API function from a managed .NET program you are using a Platform Invoke (P/Invoke) in order to call a function within a native .dll from a managed code assembly.

    If you were using these call-conventions in a native code program they would be handled differently.

    call-convention 66 is a dynamic Windows API call that resolves the call at run-time after loading the appropriate Windows library in this case kernel32.dll.

    call-convention 74 is a static Windows API call that resolves the call at link time by linking in the appropriate import library in this case kernel32.lib.

    Because there is no link step involved in creating a managed code assembly these two call conventions are treated the same, as dynamic.

    This means that kernel32.dll needs to be loaded prior to the call being made.

    You can do this in two ways:

    1. by adding a reference in your project to the appropriate kernel32.dll in either the Windows\system32 folder or Windows\sysWOW64 fol;der if you are creating a 32-bit assembly on a 64-bit system.

    2. Loading the library directly in your program

      01 pp procedure-pointer.

        set pp to entry "kernel32.dll"

    If you are making other Windows API calls that reside in other Windows libraries you would have to load these in the same manner.