[Wine] re: newbie tries to call windows dll function

JeeBee JeeBee at troefpunt.nl
Tue Aug 22 10:13:27 CDT 2006


Hi Dan, thanks for replying. I think I need your second option "write a
WineLib app that uses the DLL". The myfile.dll can set-up a connection
between two users, I don't know exactly how that works. It works when used in a windows api, but I want
support for users running linux as well. So, if I can make the same call
in this dll, and have it compatible, that would be great.

My first attempt is the program below. I'm sure this SendMessage proc
is there (and it takes a single string), but when I run this program it
fails with the "Could not get proc address" line. Anybody has a hint why?
myfile_dll.h looks empty apart from some includes.

Thanks in advance.

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "myfile_dll.h"

static void* (*SendMessage_pointer) (char *);

void InitializeDLLs() {
  HINSTANCE dll;
  dll = LoadLibrary("myfile.dll");
  if(!dll) {
	fprintf(stderr, "Could not load myfile.dll.\n");
	exit(1);
  }
  SendMessage_pointer = (void *) GetProcAddress(dll, "SendMessage");
  if(!SendMessage_pointer) {
	fprintf(stderr, "Could not get proc address of SendMessage.\n");
	exit(1);
  }
}

void* SendMessage(char *a) {
  return SendMessage_pointer(a);
}

int main(void) {
  InitializeDLLs();
  SendMessage("This is a test");
  return 0;
}





More information about the wine-users mailing list