Dllka wygalda tak:
library data;
uses windows,shlobj,forms;
function PobierzSciezke(parametr : integer):pchar;
var
bufor : PChar;
dir : PItemIDList;
form1:tform;
begin
form1:=tform.Create(form1);
GetMem(bufor,MAX_PATH);
SHGetSpecialFolderLocation(Form1.Handle,parametr,dir);
SHGetPathFromIDList(dir,bufor);
PobierzSciezke:=bufor;
FreeMem(bufor);
end;
function Katalogi(nazwa:pchar):pchar;stdcall;
var katalog:pchar;
begin
if nazwa='pulpit'then
result:=PobierzSciezke(CSIDL_DESKTOPDIRECTORY);
if nazwa='otoczeniesieciowe'then
result:=PobierzSciezke(CSIDL_NETHOOD);
if nazwa='czcionki'then
result:=PobierzSciezke(CSIDL_FONTS);
if nazwa='mojedokumenty'then
result:=PobierzSciezke(CSIDL_PERSONAL);
if nazwa='wyslijdo'then
result:=PobierzSciezke(CSIDL_SENDTO);
if nazwa='menustart'then
result:=PobierzSciezke(CSIDL_STARTMENU);
if nazwa='autostart'then
result:=PobierzSciezke(CSIDL_STARTUP);
if nazwa='temp'then
begin
GetMem (katalog, MAX_PATH);
GetTempPath (MAX_PATH, katalog);
result:=katalog;
end;
end;
exports
katalogi name 'katalogi';
begin
end.
A wywoluje ja tak:
function katalogi(nazwa:pchar):pchar; stdcall external 'data.dll' name 'katalogi';
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=katalogi(pchar(edit1.Text));
showmessage(pchar(s));
end;
Tak to dokladnie wyglada. Jak zmienilem zmienne string na pchar to teraz wyskakuje mi cos takiego:
Debugger Exception Notification
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 00473676 in module 'DATA.DLL'. Read of address 8BD88B23'. Process stopped. Use Step or Run to continue.
OK Help
Napisalem(skopiowalem :-)) wszystko tylko ze teraz nie wiem czy komus bedzie sie to chcialo czytac:-)--pozdrawiam PEDROS {hello}
Delphi6