我正在尝试使用Visual创建一个DLL,这个DLL是从Delphi5程序调用的。Delphi程序传入一个记录,然后在DLL中编辑该记录,Delphi程序使用结果。
例如,Delphi代码类似于以下内容:
Type dll_btvar = record
age : smallint;
name : array[0..11] of char;
value : Double;
end;
// Import the function from the dll
function foo(CVars : dll_btvar):integer; external 'exa
我维护Delphi 6遗留软件,它使用Delphi 2009 DLL中的以下文件目录选择功能:
function _SelectDirectory(ADirPath: ShortString): ShortString;
var OpenDlg: TFileOpenDialog;
begin
Result:='';
OpenDlg:=TFileOpenDialog.Create(nil);
try
OpenDlg.Options:=OpenDlg.Options+[fdoPickFolders];
if DirectoryExists(ADirPat
下面的DLL是用XE3编译的。
library MyDLL;
uses System.SysUtils, System.Classes, Vcl.Dialogs;
{$R *.res}
var
II: Integer;
function Test: Integer;
begin
Result := II;
end;
exports Test;
begin
II := 5;
ShowMessage('DLL prolog');
end.
当我从DelphiXE3或Delphi2007程序调用函数Test()时,在这两种情况下我都得到了正确的结果(5)。
我必须创建一个由VB6应用程序使用的DLL。这个DLL必须提供几个函数,其中一些必须返回字符串。
这是VB6声明:
Declare Function MyProc Lib "mylib.dll" (ByVal Param As String) As String
这就是Delphi在mylib.dll中的实现存根
function MyProc(AParam: PChar): PChar; stdcall;
var
ReturnValue: string;
begin
ReturnValue := GetReturnValue(AParam);
Result :=
我不能在delphi中使用dll的功能。我在转换类型方面遇到了一些问题。
这是我想要调用Delphi的函数:
function SyncFunc(var Type:string; var MaxUsers:integer; var ErrCode :Word):boolean;
C++代码:
unsigned char(WINAPI *SyncFunc)(PCHAR Type, INT *MaxUsers, WORD *ErrCode);
HMODULE hLib;
BOOL Res = FALSE;
WORD ErrCode = 0;
INT MaxUsers = 0;
CHAR T
我需要你的帮助拜托。我试图从Delphi 10,西雅图,从Inno安装程序(ANSI)中调用DLL中的函数。但我不明白问题出在哪里。如果我用Delphi进行应用程序,并从DLL调用这个函数,它就能很好地工作!请参见代码清单:
Delphi:
function Process(Pb: TProgressBar): Integer; stdcall;
var
I: integer;
begin
for I := 0 to 1000 do
begin
Pb.Position := I;
Pb.Update;
Sleep(10);
end;
end;
Expo
我将我的Delphi升级到2010版本,并尝试打开和运行用Delphi2006编写的应用程序。这个应用使用的是mysql by dbexpress和libmysql.dll,另一个驱动程序可以在互联网上找到。
我不能在2010年运行它。我总是收到“缺少libmysql.dll库”的提示。我试着得到它的新版本,但没有帮助。将这个库复制到几乎所有的系统目录中都没有帮助。
我不知道该怎么做,怎么连接数据库:(
我在Delphi2009项目中遇到了一个问题:它不能初始化Indy 10!这段代码以前在Delphi 2007中运行得很好(虽然我们可能使用了Indy的旧版本,但我怀疑这与它没有太大关系);
最初调用IdWinsock2.InitializeWinSock()时,会引发此异常(错误代码为998):
Project EAServer.exe raised exception class EIdWinsockStubError with message
'Error on loading Winsock2 library (WS2\_32.DLL): Invalid access to m
下面是通过DLL公开的C++函数:
double my_exposed_cpp_function(int* my_array){
int i = my_array[2]; /* i should be 3 */
my_array[2]++;
return 0;
}
下面是我的Delphi函数的声明
function dll_function(var my_array: array of integer): Real; stdcall; external myDLL name 'my_exposed_cpp_function';
下面是我想在Delphi函数中做的事情
pr
我如何从DLL中传递pchar?dll必须与其他应用程序兼容,而不仅仅是delphi。在“帮助”中,传递指向局部变量的指针是危险的,如果我们将该变量设置为全局变量,则代码将不会是线程安全的。
我们可以安全地传递一个宽字符串,但是在这种情况下,dll将不能与其他(非Delphi)应用程序兼容。
{code in dll}
function Test:pchar;
var
str:string;
begin
str:='Some string';
result:=pchar