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了,(*^__^*) 嘻嘻
好开心哦,又解决了一个问题
相关文档:
此文适合Delphi新手阅读,特别是连接数据库方面还一懂半懂甚至根本不懂的新手;
--------------------------但总体显得有点乱-------------------------
本文章以Delphi 7和SQL Server 2000为例,控件名均为系统默认,如Unit1,DataModule1,Edit1,ADOCommand1,ADODataS ......
Unt_Machine_WebDll.pas
BODY {background: #FFFFFF}
A:link { color: #0000FF}
A:visited { color: #0000FF}
A:Active { color: #0000FF}
.bold {font-weight: bold}
.italic {font-style: italic}
.underline {text-decoration: underline}
unit Unt_Machine_WebDll;
{$WARN SYMBOL_PLATFORM OF ......
常用控件命名前缀
控件类名
前缀
TForm等窗体类
frm
TButton, TSpeedButton等所有的按钮类
btn
TCheckBox等所有的检查框
chk
TRadioButton单选按钮类
rdo
TListBox等所有的列表框类
lst
TPanel等所有的面板类
pnl
TLabel, TStaticText等所有用来显示的标签类
lbl
TE ......
◇[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 ......
procedure TForm1.Button1Click(Sender: TObject);
Var
Num: Integer;
Begin
Try
Num:=StrToInt(Edit1.Text);
Edit2.Text:=IntToStr(Num*Num);
Except
On EConvertError Do ShowMessage(Edit1.Text+'无法转成整数!');
......