October 24th, 2004, 04:24 PM
working about a to make a function to work.. help!
anybody knows NetShareEnum ? of curse not delphi doesnt have in at any units.. its function from msdn so i delcare it
i am about a week to make it work but it keeps to crash and crash like nothing, so i tut somthing not good with my declare so i even tryed with NetShareEnum from the new api libary
here is my codes, with 2 trys maby anybody can help me out.
October 24th, 2004, 08:04 PM
There were a few problems concerning how you were passing parameters to the NetShareEnum function.
Looking at this code:
You were passing PDWORDs to the function but you did not create any DWORD variables for the results to be stored in.
EntRead, ResHandle, EntTotal: PDWORD;
NetShareEnum(nil, 0, lpBuffer, dword(-1), EntRead, EntTotal, ResHandle);
Also in this line:
you are getting the address of the lpBuffer pointer but what you need to do is cast the pointer to PShareInfo0.
SharesInfo := @lpBuffer;
Try the following modified code:
SharesInfo, p: PShareInfo0;
EntRead, ResHandle, EntTotal: DWORD;
NetApiStatus := NetShareEnum(nil, 0, pb, dword(-1),
@EntRead, @EntTotal, @ResHandle);
SharesInfo := PShareInfo0(pb);
if (NetApiStatus = ERROR_SUCCESS)
or (NetApiStatus = ERROR_MORE_DATA) then
p := SharesInfo;
for Counter := 0 to EntRead-1 do
else WriteLn('Error: '+IntToStr(NetApiStatus));
until (NetApiStatus <> ERROR_MORE_DATA);
October 25th, 2004, 03:35 PM
i dont know what to say for those help, u just didnt wrote the fixed code, u wrote the problems and thats very helped me i want to thank u very much for explaining it like this keep it up..
October 25th, 2004, 03:51 PM
why are u incrssing the P ?
E.G : Inc(p);
October 25th, 2004, 07:11 PM
NetShareEnum generates a list of PShareInfo0 records. Inc(p) increments the pointer 'p' to point to the next record.