Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/samples/simpledll/dll.cpp')
-rw-r--r--winsup/mingw/samples/simpledll/dll.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/winsup/mingw/samples/simpledll/dll.cpp b/winsup/mingw/samples/simpledll/dll.cpp
new file mode 100644
index 000000000..0c0240685
--- /dev/null
+++ b/winsup/mingw/samples/simpledll/dll.cpp
@@ -0,0 +1,44 @@
+//
+// This is a C++ version of the code in dll.c. NOTE that you need to put
+// extern "C" { ... } around DllMain or it will not be called when your
+// Dll starts up! (It will get name mangled as a C++ function and the C
+// default version in libmingw32.a will get called instead.)
+//
+
+#include <windows.h>
+
+#include <iostream>
+
+extern "C" {
+
+BOOL WINAPI
+DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
+{
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ cout << "Dll Attached" << endl ;
+ break;
+
+ case DLL_PROCESS_DETACH:
+ cout << "Dll Detached" << endl ;
+ break;
+
+ case DLL_THREAD_ATTACH:
+ printf ("DLL Thread Attached.\n");
+ break;
+
+ case DLL_THREAD_DETACH:
+ printf ("DLL Thread Detached.\n");
+ break;
+ }
+ return TRUE;
+}
+
+void
+Test ()
+{
+ printf ("Test Function called!\n");
+}
+
+};