delphi中调用API函数出问题
刚开始用delphi调用api函数,有很多地方不熟procedure TForm1.Button1Click(Sender: TObject);
var
text:array[0..255] of char;
jb:hwnd;
begin
sendmessage(jb,wm_gettext,255,longint(@text));
if pos('程序测试',text)>0 then
showwindow(jb,sw_show);
sendmessage(jb,wm_keydown,vk_f12,0);
end;
end.
主要是在程序测试这个已经打开的程序中,按下F12调出程序测试F12的另外一个窗口,测试没有反映,不知哪里有问题,多谢! delphi api 测试 --------------------编程问答-------------------- if pos('程序测试',text)>0 then
这一句有问题,text是char类型的数组怎么能跟字符串去比较呢,可以改成Tmp:=StrPas(@text[0]);
if pos('程序测试',text)>0 then
还有你定义的jb根本没给它赋值,程序压根不知道这是什么句柄,你得把要接受消息的窗体的句柄赋值给它 --------------------编程问答-------------------- var text : array[0..255] of ansiChar;
begin
sendmessageA(Form1.handle,wm_gettext,255,longint(@text));
if pos(strpas('or'),strpas(text)) > 0 then
windows.MessageBoxA(0, text, '程序测试', 0)
end; --------------------编程问答-------------------- 看起来是对的
补充:.NET技术 , 其他语言