bookmist
|
Posted: Sat May 06, 2006 16:00 Post subject: Total не заходит в пустую папку при использовании WideString |
|
|
Пишу плагин менеджер библиотеки, и столкнулся со странной проблемой. Тотал то заходил в пустые папки в плагине, то ругался и не заходил. Попытавшись локализовать ошибку пришёл к абсурдному варианту.
Code: |
library MyLib;
{$E wfx}
uses Windows;
type
TProgressProc=function(PluginNr:integer;SourceName,TargetName:pchar;PercentDone:integer):integer; stdcall;
TLogProc=procedure(PluginNr,MsgType:integer;LogString:pchar); stdcall;
TRequestProc=function(PluginNr,RequestType:integer;CustomTitle,CustomText,ReturnedText:pchar;maxlen:integer):bool; stdcall;
function FsInit(PluginNr:integer;pProgressProc:tProgressProc;pLogProc:tLogProc;
pRequestProc:tRequestProc):integer; stdcall;
begin result:=0; end;
function FsFindFirst(path :pchar;var FindData:tWIN32FINDDATA):thandle; stdcall;
var
sql_req:widestring;
begin
sql_req:='_';{Если эта строка выполняеся, то тотал не заходит в плагин}
SetLastError(ERROR_NO_MORE_FILES);
result:=INVALID_HANDLE_VALUE;
end;
function FsFindNext(Hdl:thandle;var FindData:tWIN32FINDDATA):bool; stdcall;
begin result:=false; end;
function FsFindClose(Hdl:thandle):integer; stdcall;
begin result:=0; end;
exports
FsInit, FsFindFirst, FsFindNext, FsFindClose;
end.
|
Оригинальная функция из моего плагина:
Code: |
function FsFindFirst(path :pchar;var FindData:tWIN32FINDDATA):thandle; stdcall;
var
hdl:TADODataSet;
sqlreq:string;
begin
FillChar(FindData,sizeof(FindData),0);
result:=INVALID_HANDLE_VALUE;
hdl:=nil;
try
sqlreq:=GetSQLrequest(path);
if sqlreq='' then SetLastError(ERROR_NO_MORE_FILES)
else begin
hdl:=TADODataSet.Create(DBConn);
hdl.Connection:=DBConn;
hdl.CursorType:=ctOpenForwardOnly;
hdl.CommandType:=cmdText;
hdl.CommandText:=sqlreq;{}
hdl.Active:=True;
hdl.First;
if (not hdl.IsEmpty)and(FsFindNext(hdl,FindData)) then result:=cardinal(hdl)
else begin SetLastError(ERROR_NO_MORE_FILES); hdl.Free;{Плагин не заходит в папку, если выполняется этот код} end;
end;
except
if hdl<>nil then hdl.Free;
result:=INVALID_HANDLE_VALUE;
end;
end;
|
Может кто- нибудь сказать: как проостое использование WideString приводит к таким странным результатам. Причём если присваиваешь sql_req пустую строку, то всё работает нормально.
Пишу на Delphi6, версия TotalCommander 6.54a (16.2.2006) |
|