标题:[求助]请大家帮我看看我在DELPHI中调用VC写的DLL,有哪写错了,谢谢!
取消只看楼主
我爱论坛
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2004-12-3
 问题点数:0 回复次数:1 
[求助]请大家帮我看看我在DELPHI中调用VC写的DLL,有哪写错了,谢谢!

这个函数
DLLEXPORT DWORD IdleUIGetLastInputTime()
{
return g_dwLastInputTick;
}
我编成这个,说是无法定位程序输入点。
function IdleUIGetLastInputTime:DWORD;
stdcall; external 'IdleUI.dll'
name 'IdleUIGetLastInputTime';
VC的DLL全部源代码:
////////////////////////////////////////////////////////////////
// 2000 VCKBASE Online Journal.
// This program compiles with Visual C++ 6.0 on Windows 98
//
// See IdleUI.h
//
#include <afxwin.h> // MFC core and standard components

#define DLLEXPORT __declspec(dllexport)

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////
// App object for this DLL
//
class CTestIdleUIDll : public CWinApp {
public:
CTestIdleUIDll() { }
~CTestIdleUIDll() { }
} theDll; // one-and-only, normal (per-process) static global

////////////////
// The following global data is SHARED among all instances of the DLL
// (processes); i.e., these are system-wide globals.
//
#pragma data_seg (".IdleUI") // you must define as SHARED in .def
HHOOK g_hHookKbd = NULL; // one instance for all processes
HHOOK g_hHookMouse = NULL; // one instance for all processes
DWORD g_dwLastInputTick = 0; // tick time of last input event
#pragma data_seg ()

/////////////////
// Get tick count of last keyboard or mouse event
//
DLLEXPORT DWORD IdleUIGetLastInputTime()
{
return g_dwLastInputTick;
}

/////////////////
// Keyboard hook: record tick count
//
LRESULT CALLBACK MyKbdHook(int code, WPARAM wParam, LPARAM lParam)
{
if (code==HC_ACTION) {
g_dwLastInputTick = GetTickCount();
}
return ::CallNextHookEx(g_hHookKbd, code, wParam, lParam);
}

/////////////////
// Mouse hook: record tick count
//
LRESULT CALLBACK MyMouseHook(int code, WPARAM wParam, LPARAM lParam)
{
if (code==HC_ACTION) {
g_dwLastInputTick = GetTickCount();
}
return ::CallNextHookEx(g_hHookMouse, code, wParam, lParam);
}

//////////////////
// Initialize DLL: install kbd/mouse hooks.
//
DLLEXPORT BOOL IdleUIInit()
{
if (g_hHookKbd == NULL) {
HINSTANCE hInst = theDll.m_hInstance;
g_hHookKbd = SetWindowsHookEx(WH_KEYBOARD, MyKbdHook, hInst, 0);
g_hHookMouse = SetWindowsHookEx(WH_MOUSE, MyMouseHook, hInst, 0);
g_dwLastInputTick = GetTickCount(); // init count
}
ASSERT(g_hHookKbd);
ASSERT(g_hHookMouse);
return TRUE;
}

//////////////////
// Terminate DLL: remove hooks.
//
DLLEXPORT void IdleUITerm()
{
BOOL bRet1 = UnhookWindowsHookEx(g_hHookKbd);
BOOL bRet2 = UnhookWindowsHookEx(g_hHookMouse);
ASSERT(bRet1 && bRet2);
}

搜索更多相关主题的帖子: DELPHI DLL 源代码 DWORD 
2005-11-08 23:46
我爱论坛
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2004-12-3
得分:0 

难道版主也是初学者?

2005-11-11 00:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-33127-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.208733 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved