注册 登录
编程论坛 VB6论坛

DllMain 里,SetTimer定时器一点反应也没有

atfeel 发布于 2013-04-13 13:54, 835 次点击
Public Function DllMain(ByVal hinstDLL As Long, ByVal fdwReason As Long, ByVal lpvReserved As Long) As Long
    Dim riid        As UUID
    Dim aiid        As UUID
    Dim lpDllGetObj As Long
   
    Select Case fdwReason
    Case DLL_PROCESS_ATTACH                                                     '加载
        CreateIExprSrvObj 0, 4, 0
        CoInitialize 0
        lpDllGetObj = GetProcAddress(hinstDLL, "DllGetClassObject")
        CopyMemory gvbtab, ByVal lpDllGetObj + 2, 4
        CopyMemory gvb, ByVal lpDllGetObj + 7, 4
        CopyMemory gloaders, ByVal lpDllGetObj + 12, 4
        With riid
            .Data1 = 1
            .Data4(0) = &HC0
            .Data4(7) = &H46
        End With
        DllMain = UserDllMain(gloaders, gvb, hinstDLL, fdwReason, lpvReserved)
        VBDllGetClassObject gloaders, gvb, gvbtab, aiid, riid, ofac
        CopyMemory gvbtab, ByVal lpDllGetObj + 2, 4
        CopyMemory gvb, ByVal lpDllGetObj + 7, 4
        CopyMemory gloaders, ByVal lpDllGetObj + 12, 4
        
        '自定义内容
        
        'TimerProc
        Handle = FindWindow(vbNullString, "Program manager")
        lngTimerID = SetTimer(Handle, 0, 1000, AddressOf TimerProc)             'SetTimer第一个参数是进程句柄,第二个是timer的编号,第三个是时间间隔。第四个参数是一个回调函数。
        
    Case DLL_PROCESS_DETACH                                                     '卸载
        CoUninitialize
        DllMain = UserDllMain(gloaders, gvb, hinstDLL, fdwReason, lpvReserved)
        KillTimer Handle, lngTimerID
    End Select
End Function


Public Function TimerProc()
    MsgBox (Now)
End Function

各位呀,谁帮下忙呀
2 回复
#2
bczgvip2013-04-13 22:51
需要重定位入口 DllMain ,编译后才能使用。
话说没有详细看说明文档么?
#3
atfeel2013-04-14 09:54
回复 2楼 bczgvip
最近才开始接触这方面,如何重新定位DLLMAIN入口,在那里有说明文档,我走投无路了。请版主大人出手解答
1