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 , isnullschar) : 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 , isnullschar) : 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) char;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却出现非
法操作了,不知为何?
请大虾们赐教!!!!
二个及以后声明的函数我都调用不了,一调用,就非法操作。
我的DLL是这样声明的:
library GWMSPT;
uses
ShareMem,
SysUtils,
Classes,
MSUPORRT in 'MSUPORRT.pas',
TYPEMATCHH in 'TYPEMATCHH.pas';
{$R *.RES}
function GetSql_CreateTable(TableName,ColumnNames ,Types , isnullschar) : 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 , isnullschar) : 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) char;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却出现非
法操作了,不知为何?
请大虾们赐教!!!!