Calling libgpgme-11.dll from Visual basic 6
Franklin Hu
franklinhu at yahoo.com
Thu Oct 15 19:36:09 CEST 2009
I have been able to find the Win32 version of the gpgme library called libgpgme-11.dll from the gpg4win package. I am trying to figure out how to call it from visual basic 6. I have first started by looking how to call C dlls from vb:
http://support.microsoft.com/kb/106553
I want to call the gpgme_new function which takes one parameter which is a context. It is declared in the .h file (used when calling from c++) as:
/* The context holds some global state and configration options, as
well as the results of a crypto operation. */
struct gpgme_context;
typedef struct gpgme_context *gpgme_ctx_t;
/* Create a new context and return it in CTX. */
gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
To start, I just tried to set it up and call it like:
Declare Function gpgme_new Lib "libgpgme-11.dll" (ctx)
Sub Main()
Dim ctx
Dim gpgme_error
gpgme_error = gpgme_new(ctx)
End Sub
It is able to find the dll and the reference to gpgme_new. If I put in the name of a function which doesn't exist, it complains. But it comes back with the error:
Run-time error '49':
Bad DLL calling convention
I looked up this error and found:
http://support.microsoft.com/kb/85108
This said something about calling ByVal which I tried and that didn't do anything. Seems to me, I need to figure out just what kind of object the ctx is and specify that specific type
in the declaration. The way it is declared, it just looks like a pointer, but VB doesn't have a pointer type.
I'm a beginner to this whole gpg and calling DLL thing. So I'm not even sure that it is possible to do this or if I'm just making a silly mistake in the declaration. If anyone can help out on how to call this dll, I would appreciate it.
-thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20091015/08558a4c/attachment.htm>
More information about the Gnupg-users
mailing list