aboutsummaryrefslogtreecommitdiff
path: root/pd/portmidi/pm_win/pmdll.c
blob: c3acba33e768c97e651de4d53af4b5e0f57642c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
====================================================================
DLL to perform action when program shuts down
====================================================================
*/

#include "windows.h"
#include "pmdll.h"

static close_fn_ptr_type close_function = NULL;


DLL_EXPORT pm_set_close_function(close_fn_ptr_type close_fn_ptr)
{
    close_function = close_fn_ptr;
}


static void Initialize( void ) {
    return;
}

static void Terminate( void ) {
    if (close_function) {
        (*close_function)();
    }
}


BOOL WINAPI DllMain(HINSTANCE hinstDLL, //DLL module handle
					DWORD fdwReason,	//for calling function
					LPVOID lbpvReserved)//reserved
{
	switch(fdwReason) {
		case DLL_PROCESS_ATTACH:
			/* when DLL starts, run this */
			Initialize();
			break;
		case DLL_PROCESS_DETACH:
			/* when DLL ends, this run (note: verified this	run */
			Terminate();
			break;
		default:
			break;
	}
	return TRUE;
}