关于DLL的声明的问题。(斑竹快来!!!!!!!!!急)(50分)

  • 主题发起人 主题发起人 kinn_liu
  • 开始时间 开始时间
K

kinn_liu

Unregistered / Unconfirmed
GUEST, unregistred user!
我用DELPHI写的DLL,DELPHI调用,遇到这样的问题:我只能调用第一个声明的函数,第
二个及以后声明的函数我都调用不了,一调用,就非法操作。

我的DLL是这样声明的:

library GWMSPT;
uses
ShareMem,
SysUtils,
Classes,
MSUPORRT in 'MSUPORRT.pas',
TYPEMATCHH in 'TYPEMATCHH.pas';

{$R *.RES}
function GetSql_CreateTable(TableName,ColumnNames ,Types , isnulls:pchar) : pchar
stdcall;
begin
result := pchar(getsql_createtableA(TableName,ColumnNames ,Types,isnulls));
end;
function GetSql_DropTable(Tablename : pchar) : pchar;
begin
result := pchar(getsql_droptableA(tablename));
end;
...
...
exports
GetSql_CreateTable,
GetSql_DropTable ,
GetSql_AddColumn,
GetSql_DropColumn,
GetSql_CreatePrimaryKey,
GetSql_DropPrimaryKey,
GetSql_Insert,
GetSql_Update,
GetSql_Delete;
begin
end.

我在调用程序中采用静态引入方式:
是这样写的:

unit MsupportDllH;

interface
uses classes,dbtables,db;
const
MsupportDll = 'GWMSPT.dll'

//====================
function GetSql_CreateTable(TableName : string;ColumnNamelist ,Typelist, isnulllist :Tstringlist) : string;
function GetSql_DropTable(Tablename : string) : string;
...
//================================

implementation
//declare external
function GetSql_CreateTableA(TableName,ColumnNames ,Types , isnulls:pchar) : pchar
stdcall;external MsupportDll name 'GetSql_CreateTable';
function GetSql_DropTableA(Tablename : pchar) : pchar
stdcall;external MsupportDll name 'GetSql_DropTable' index 2;
function GetSql_AddColumnA(Tablename,ColumnName ,Types: pchar) :pchar;stdcall;external MsupportDll name 'GetSql_AddColumn';
...
//implemente
function GetSql_CreateTable(TableName : string;ColumnNamelist ,Typelist,isnulllist:Tstringlist) : string;
var
counter : integer;
ColumnNames ,Types,isnulls : string;

begin
for counter := 0 to columnnamelist.count - 1 do
columnnames := columnnames + columnnamelist.strings[counter] + ';';
columnnames := copy(columnnames,1,length(columnnames) - 1);

for counter := 0 to typelist.count - 1 do
types := types + typelist.strings[counter] + ';';
types := copy(types,1,length(types) - 1);

for counter := 0 to isnulllist.count - 1 do
isnulls := isnulls + isnulllist.strings[counter] + ';';
isnulls := copy(isnulls,1,length(isnulls) - 1);


result :=GetSql_CreateTableA(pchar(Tablename),pchar(columnnames),pchar(types),pchar(isnulls));
end;

function GetSql_DropTable(Tablename : string) : string;
begin
result := GetSql_DropTableA(Pchar(Tablename));
end;
.....

我引用第一个函数GETSQL_CREATETABLE是可以的,可用第二个GETSQL_DROPTABLE却出现非
法操作了,不知为何?

请大虾们赐教!!!!
 

你用QuickView或者Dependency看看DLL的导出函数有哪些,名字又是什么,根据这些信息就
可以知道问题出在哪了.
 
!@#$%^&*---------(
呵呵,是我自己笔误,
第二个函数及以后都忘了写stdcall了。
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
806
import
I
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
486
import
I
I
回复
0
查看
633
import
I
后退
顶部