#define QMPLUGIN_API extern "C" __declspec(dllexport)
typedef int (*QMPLUGIN_HANDLER)(char *lpszParamList, char *lpszRetVal);
typedef struct {
char *m_lpszCommandName;
char *m_lpszCommandDescription;
QMPLUGIN_HANDLER m_pHandlerFunction;
UINT m_nParamNumber;
} QMPLUGIN_CMD_INFO;
typedef QMPLUGIN_CMD_INFO* (*CommandFunc)(int iCommandNum); HINSTANCE thDll;
thDll = LoadLibrary("xxxxxplugin.dll"); if (thDll != NULL)
{
CommandFunc someFunc = (CommandFunc)GetProcAddress(thDll, "GetCommand");
if (someFunc != NULL)
{
QMPLUGIN_CMD_INFO* abc = someFunc(0);
printf("the function description is %s\n", abc->m_lpszCommandDescription);
}else
{
printf("Load Function Error\n");
} FreeLibrary(thDll);
}else{
printf("Load DLL Error\n");
}
谢谢了!
typedef int (*QMPLUGIN_HANDLER)(char *lpszParamList, char *lpszRetVal);
typedef struct {
char *m_lpszCommandName;
char *m_lpszCommandDescription;
QMPLUGIN_HANDLER m_pHandlerFunction;
UINT m_nParamNumber;
} QMPLUGIN_CMD_INFO;
typedef QMPLUGIN_CMD_INFO* (*CommandFunc)(int iCommandNum); HINSTANCE thDll;
thDll = LoadLibrary("xxxxxplugin.dll"); if (thDll != NULL)
{
CommandFunc someFunc = (CommandFunc)GetProcAddress(thDll, "GetCommand");
if (someFunc != NULL)
{
QMPLUGIN_CMD_INFO* abc = someFunc(0);
printf("the function description is %s\n", abc->m_lpszCommandDescription);
}else
{
printf("Load Function Error\n");
} FreeLibrary(thDll);
}else{
printf("Load DLL Error\n");
}
谢谢了!
解决方案 »
- 在Image上DrawText任意格式的字???
- 明天结婚与大家分享一下快乐
- ss
- 请高手门看过来啊有关DELPHI当中解压缩的问题啊见人有分啊请各位高手发言啊
- ADO操作VFP数据表,高分求教!急用
- 我想请问 fieldbyname 能不能实现多表数据的输出呢?
- 如何在自己的程序中控制FastReport报表中的对象?
- 用dbExpress如何取得MSSQL SERVER2000的数据?
- 有谁做过文档中心猛禽先生的《用 SOAP 实现三层数据库应用》例子?是不是机器上必须得有IIS呀?
- 为什么在把数据库中的blob字段读出写到memo时会报错?(急)!!!
- 小弟现在在学习Delphi 7,各位大虾有没有什么入门书籍可以推荐啊,谢谢
- Image怎样加载ImageList中的图像
type
QMPLUGIN_CMD_INFO= record
m_lpszCommandName,
m_lpszCommandDescription:Pchar;
m_pHandlerFunction:QMPLUGIN_HANDLER;
m_nParamNumber:Cardinal;
end;
pQMPLUGIN_CMD_INFO=^QMPLUGIN_CMD_INFO;type CommandFunc= function (iCommandNum:integer):pQMPLUGIN_CMD_INFO;var
thDll:HINSTANCE;
someFunc: CommandFunc;
begin
thDll := LoadLibrary('xxxxxplugin.dll');
if (thDll <>nil) then
begin
someFunc:= GetProcAddress(thDll, 'GetCommand');
if (someFunc<>nil) then begin
QMPLUGIN_CMD_INFO* abc = someFunc(0);
printf('the function description is %s', abc->m_lpszCommandDescription);
end
else
printf('Load Function Error');
FreeLibrary(thDll);
end
else
printf('Load DLL Error');
end;
谢谢兄弟,不过好像有点问题,请问你在Delphi里面能用吗?
var
thDll:HINSTANCE; 通不过
someFunc: CommandFunc;
begin
thDll := LoadLibrary('xxxxxplugin.dll');
if (thDll <>nil) then (改成hwnd后通不过)
begin
someFunc:= GetProcAddress(thDll, 'GetCommand');
if (someFunc <>nil) then begin (通不过)
QMPLUGIN_CMD_INFO* abc = someFunc(0); (通不过)
printf('the function description is %s', abc->m_lpszCommandDescription); (通不过,不过不重要)
end
else
printf('Load Function Error');
FreeLibrary(thDll);
end
else
printf('Load DLL Error');
type
QMPLUGIN_CMD_INFO= record
m_lpszCommandName,
m_lpszCommandDescription:Pchar;
m_pHandlerFunction:QMPLUGIN_HANDLER;
m_nParamNumber:Cardinal;
end;
pQMPLUGIN_CMD_INFO=^QMPLUGIN_CMD_INFO; type CommandFunc= function (iCommandNum:integer):pQMPLUGIN_CMD_INFO; var
thDll:THANDLE;
someFunc: CommandFunc;
begin
thDll := LoadLibrary('xxxxxplugin.dll');
if (thDll <>0) then
begin
someFunc:= GetProcAddress(thDll, 'GetCommand');
if (someFunc <>nil) then begin
result = someFunc(0);
..
end
else
...
FreeLibrary(thDll);
end
else
...
end;
原文:
在自己的程序中调用按键精灵的插件 末看了一下按键精灵的使用方法,关注了一下它里面提到的插件编写方法。
它的插件套路是这样的, 你使用他们提供的一个插件模板编写一个DLL,
这样编译完你的DLL就默认支持4个基本接口
(使用dumpbin /exports随便一个插件DLL就可以看到)
ordinal hint RVA name 1 0 00001032 GetCommand
2 1 00001014 GetCommandCount
3 2 00001023 GetFormatVersion
4 3 0000102D GetPluginDescription假设你要在按键精灵里面调用插件ABC.DLL里面的say方法,
那么脚本这样写:
Plugin ABC.say()
按键精灵会加载ABC.DLL,然后通过GetCommand,GetCommandCount这样的方法对插件进行轮询,
直到找到一个叫Say的commmand入口,然后调用之。我不知道按键精灵对这些别人写的插件是怎么进行验证的, 如果没有源码级别的检查, 那插件里面包含木马应该很难避免。知道了插件的接口,不想通过按键精灵, 想自己在程序里面直接调用这些插件方法也很EASY了,
下面是一个简单的例子:
#define QMPLUGIN_API extern "C" __declspec(dllexport)
typedef int (*QMPLUGIN_HANDLER)(char *lpszParamList, char *lpszRetVal);
typedef struct {
char *m_lpszCommandName;
char *m_lpszCommandDescription;
QMPLUGIN_HANDLER m_pHandlerFunction;
UINT m_nParamNumber;
} QMPLUGIN_CMD_INFO;
typedef QMPLUGIN_CMD_INFO* (*CommandFunc)(int iCommandNum); HINSTANCE thDll;
thDll = LoadLibrary("xxxxxplugin.dll"); if (thDll != NULL)
{
CommandFunc someFunc = (CommandFunc)GetProcAddress(thDll, "GetCommand");
if (someFunc != NULL)
{
QMPLUGIN_CMD_INFO* abc = someFunc(0);
printf("the function description is %s\n", abc->m_lpszCommandDescription);
}else
{
printf("Load Function Error\n");
} FreeLibrary(thDll);
}else{
printf("Load DLL Error\n");
}
以下是偶测试过的,可编译通过type QMPLUGIN_HANDLER = function(lpszParamList, lpszRetVal: PChar): integer; stdcall;
type
QMPLUGIN_CMD_INFO = record
m_lpszCommandName,
m_lpszCommandDescription: Pchar;
m_pHandlerFunction: QMPLUGIN_HANDLER;
m_nParamNumber: Cardinal;
end;
pQMPLUGIN_CMD_INFO = ^QMPLUGIN_CMD_INFO;type CommandFunc = function(iCommandNum: integer): pQMPLUGIN_CMD_INFO;var
thDll: Cardinal;
someFunc: CommandFunc;
abc: pQMPLUGIN_CMD_INFO;
begin
thDll := LoadLibrary('xxxxxplugin.dll');
if (thDll <> 0) then begin
someFunc := GetProcAddress(thDll, 'GetCommand');
if Assigned(someFunc) then begin
abc := someFunc(0);
ShowMessage(Format('the function description is %s', [abc^.m_lpszCommandDescription]));
end
else
ShowMessage('Load Function Error');
FreeLibrary(thDll);
end
else
ShowMessage('Load DLL Error');
end;
谢谢了啊老大!
本来是打算调用按键精灵的dll插件的,可是奈何自己的功力太差了,用上面的代码也没办法进入到那些个DLL里面去,郁闷ing....
结帐,面壁去!老大你一会要是有时间,心情不错能帮忙完成一下调用按键精灵的DLL的功能不,3Q!