Jump to content

passing file pointer to c dll in dllcall


Recommended Posts

in calls to winapi file handle passes as HANDLE and all ok.

but in plain C it may be FILE*

ex:

RHASH_API void rhash_run_benchmark(unsigned hash_id, unsigned flags,
                   FILE* output);


calls like

  Local $aResult = DllCall("librhash.dll", "none:cdecl", "rhash_run_benchmark", _
    "uint", $hash_id, _
    "uint", $flags, _
    "handle", $output)

crashes

(i try handle, handle*, ptr, ptr*, hwnd, hwnd*, ....)

may be someone know solution ?

Link to comment
Share on other sites

the solution is modify source c dll code (write wrapper c func)

like this

void rhash_run_benchmark_mod(unsigned hash_id, unsigned flags, const char* output)
{
    FILE* f = fopen(output, "wb");
    rhash_run_benchmark(hash_id, flags, f);
        fclose(f);
}

not the case if no source code for dll :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...