blob: 7483e9f07073f28878ddd2e177c10a074c5406f6 [file] [log] [blame]
Yun Penga93e9de2016-06-30 14:27:38 +00001#include <stdio.h>
2#include <windows.h>
3typedef char *(__cdecl *GET_TIME_PTR)();
4typedef void(__cdecl *SAY_HELLO_PTR)(char *);
5
6int main() {
7 HINSTANCE hellolib;
8 GET_TIME_PTR get_time;
9 SAY_HELLO_PTR say_hello;
10
11 bool success = FALSE;
12
13 hellolib = LoadLibrary(TEXT("hellolib.dll"));
14
15 if (hellolib != NULL) {
16 get_time = (GET_TIME_PTR)GetProcAddress(hellolib, "get_time");
17 say_hello = (SAY_HELLO_PTR)GetProcAddress(hellolib, "say_hello");
18
19 if (NULL != get_time && NULL != say_hello) {
20 success = TRUE;
21 char *now = get_time();
22 say_hello(now);
23 }
24 FreeLibrary(hellolib);
25 }
26
27 if (!success) printf("Failed to load dll and call functions\n");
28
29 return 0;
30}