DELPHI调用VC编写的DLL 函数参数为LPTSTR
注意点:LPTSTR 对应的是PAnsiChar 或者PWideChar 你问问他的编译选项,要是定义了unicode就是PWideChar 否则是PAnsiChar
这里我是用UNICODE编程的,所以用到的是PWideChar
在VC写的A.dll里添加一个函数为
extern "C" __declspec(dllexport) LPTSTR WINAPI Do(LPTSTR i)
{
return i;
}
在DELPHI调用为
type
TDoFunc=function(str:PWideChar) :PWideChar;stdcall;
var
Th:Thandle;
TDo:TDoFunc;
Tp:TFarProc;
str:PWideChar;
strA,strB:PWideChar;
begin
Th:=LoadLibrary('A.dll'); {装载DLL}
if Th>0 then
try
Tp:=GetProcAddress(Th,PChar('_Do@4'));
if Tp<>nil
then begin
TDo:=TDoFunc(Tp);
strA:='bread';
str:=TDo(strA);
ShowMessage(str);
end
else
ShowMessage('没有找到函数');
finally
FreeLibrary(Th); {释放DLL}
end
else
ShowMessage('dll文件没找到');
end;
这样就OK了,(*^__^*) 嘻嘻
好开心哦,又解决了一个问题
相关文档:
有时需要使用透明控件用于捕获鼠标消息
1.调用Windows2000,xp新的API函数实现这一功能的过程。使用SetLayeredWindowAttributes
2.直接设置控件的alphablend,alphablendvalue,间接调用上述api.
3.使用TStaticText控件
procedure WMCtrlColor(var Message: TWMCtlColor); message WM_CTLCOLOR;
procedure TForm3.WMCtr ......
◇[DELPHI]产生鼠标拖动效果
通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL:
var xpanel,ypanel,xlabel,ylabel:integer;
PANEL的MouseMove事件:xpanel:=x;ypanel:=y;
PANEL的DragOver事件:xpanel:=x;ypanel:=y;
LABEL的MouseMove事件:xlabel:=x;ylabel:=y;
LABEL的EndDrag事件:label ......
一个很简单的问题,但我凭我学习C++/VC一年多,接触Delphi的时间也不短了,但仍然写不出来。
本来以为,不就是将Form1.Show和Form1.Hide么,但却就是达到不到自己想要的结果
这个问题倒不用作深入研究了,到是让我发现,Delphi也不是信手摘来,什么都是那么容易的,以为自己有点儿VC的底子,就小看了Delphi。
最近一段时 ......
Delphi 与 C/C++ 数据类型对照表
Delphi数据类型C/C++
ShorInt
8位有符号整数
char
Byte
8位无符号整数
BYTE,unsigned short
SmallInt
16位有符号整数
short
Word
16位无符号整数
unsigned short
Integer,LongInt
32位有符号整数
int,long
Cardinal,LongWord/DWORD
32位无符号整数
unsigned long
Int6 ......