Added a dll hello world example program
run following commands to test it:
bazel build --cpu=x64_windows_msvc examples/windows/dll:hello
./bazel-bin/examples/windows/dll/hello
--
Change-Id: I096f6ff66473b1c9980b0aa36ec291f39512dd71
Reviewed-on: https://bazel-review.googlesource.com/#/c/3932
MOS_MIGRATED_REVID=126300284
diff --git a/examples/windows/dll/hello-world.cpp b/examples/windows/dll/hello-world.cpp
new file mode 100644
index 0000000..7483e9f
--- /dev/null
+++ b/examples/windows/dll/hello-world.cpp
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <windows.h>
+typedef char *(__cdecl *GET_TIME_PTR)();
+typedef void(__cdecl *SAY_HELLO_PTR)(char *);
+
+int main() {
+ HINSTANCE hellolib;
+ GET_TIME_PTR get_time;
+ SAY_HELLO_PTR say_hello;
+
+ bool success = FALSE;
+
+ hellolib = LoadLibrary(TEXT("hellolib.dll"));
+
+ if (hellolib != NULL) {
+ get_time = (GET_TIME_PTR)GetProcAddress(hellolib, "get_time");
+ say_hello = (SAY_HELLO_PTR)GetProcAddress(hellolib, "say_hello");
+
+ if (NULL != get_time && NULL != say_hello) {
+ success = TRUE;
+ char *now = get_time();
+ say_hello(now);
+ }
+ FreeLibrary(hellolib);
+ }
+
+ if (!success) printf("Failed to load dll and call functions\n");
+
+ return 0;
+}