To:wr960204
以下是我的源码,请检查,与您的是否不同:
/////////////////////////////////////////////////////////////////////////
以下是主程序的相关代码:
。。。。。。
Type
PQuery= ^TQuery;
implementation
uses main, WS, JXC, ReportJXC, ReportWS;
{$R *.DFM}
procedure FLogin(PqryBasic: PQuery
const UserName, Password, Log: WideString)
StdCall
external 'Basic.dll';
。。。。。。
procedure TLogin.Login(const UserName, Password, Log: WideString);
begin
FLogin(@qryBasic, UserName, Password, Log)
//qryBasic是主程序中的TQuery的实例
end;
。。。。。。
/////////////////////////////////////////////////////////////////////////
以下是主程序调用的Basic.dll的相关代码:
//下面是Basic.dll的项目文件Basic.dpr的相关代码
library Basic;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
ShareMem,
SysUtils,
Classes,
Main in 'Main.pas';
{$R *.res}
exports
FLogin Index 1,
。。。。。。
begin
end.
//下面是Basic.dll的项目文件Basic.dpr调用的单元文件Main.pas的相关代码:
unit Main;
interface
uses
ShareMem, SysUtils, DBTables;
Type
PQuery= ^TQuery;
procedure FLogin(PqryBasic: PQuery
const UserName, Password, Log: WideString)
StdCall;
。。。。。。
implementation
{对登陆客户进行身份验证,若合法,则添加他的名字到列表框中,设置FLoggedIn登
陆标志为True。}
procedure FLogin(PqryBasic: PQuery
const UserName, Password, Log: WideString);
var
i: Integer;
begin
if Log='Login' then
with PqryBasic^ do begin
Close;
Sql.Clear;
sql.Append('If Exists (Select UserName from UserDefine where UserName='+ ''''+ UserName+ ''''+ ' and Password='+ ''''+ Password+ ''''+ ')');
Sql.Append('Select 1 as MyLog');
Sql.Append('else Select 0 as MyLog');
。。。。。。
///////////////////////////////////////////////////////////////////////////
下面是程序调试时候的错误提示:
InValid Pointer Operatioin
错误过程描述:
当我用客户端登陆系统,进行帐号与密码(UserName &
Password)的验证,调用
Basic.dll中的FLogin()函数,发生错误。
本人共有210分,对于第一个解决问题的高人,本人将全部奉上。