;-------------------------------------------------------------------------------
;  colibrary procedure DllMain
;
; -------------------------------------------------------
; This procedure was written by Ernest Murphy    9/27/00
;
; Copyright (c) 9/28/00  Ernest Murphy
; For educational use only. Any commercial re-use only by written license
;
; -------------------------------------------------------
.NOLIST
.386
.model flat, stdcall  ; 32 bit memory model
option casemap :none  ; case sensitive

include     mini_win.inc	; 'just enough' of windows.inc (speeds build)
include     \masm32\include\oleaut32.inc
include     \masm32\include\ole32.inc
include     \masm32\include\kernel32.inc
include     \masm32\COM\include\oaidl.inc

include     colib.inc

externdef   g_hModule:DWORD       
externdef   g_hHeap:DWORD       

PUBLIC g_hModule    

.data

g_hModule               DWORD           0
g_hHeap                 DWORD           0


.code
;-------------------------------------------------------------------------------

DllMain PROC PUBLIC hModule:HANDLE, dwReason:DWORD, pReserved:DWORD

             
;-------------------------------------------------------------------------------
; COM server dll main export
;   The DllMain function is the method of entry into COM server
;    dynamic-link library 
;   
;
; EXAMPLE:
;   invoke DllGetClassObject, ADDR clsid, ADDR iid:DWORD, ADDR pv
;
; Uses: eax, ecx, edx
;
;
;-------------------------------------------------------------------------------
    .IF dwReason == DLL_PROCESS_ATTACH
        mov eax, hModule
        mov g_hModule, eax
        ; get handle for global heap
        invoke GetProcessHeap
        mov g_hHeap, eax
        mov eax, TRUE
    .ELSEIF dwReason == DLL_PROCESS_DETACH
        mov eax, TRUE
    .ELSE
        xor eax, eax        ; mov eax, FALSE
    .ENDIF
    ret
DllMain Endp
;-------------------------------------------------------------------------------

end
