cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Roman1
Level 9

Using Win Api Function NetShareGetInfo

Hello,
I'm using Windows API function NetShareGetInfo in ISScript.
This function gives back dynamically allocated buffer.
How do I read the buffer, convert it to strings?

I'd appreciate anyone's help...

Sample code:

typedef SHARE_INFO_502
begin
POINTER shi502_netname;
LONG shi502_type;
POINTER shi502_remark;
LONG shi502_permissions;
LONG shi502_max_uses;
LONG shi502_current_uses;
POINTER shi502_path;
POINTER shi502_passwd;
LONG shi502_reserved;
LONG shi502_security_descriptor;
end;

prototype NUMBER Netapi32.NetShareGetInfo (LONG, BYREF STRING,LONG, POINTER);

let's call this function:

STRING lpShare;
NUMBER res;
LONG mvarNET_API_STATUS;
LONG level;
SHARE_INFO_502 s502;
SHARE_INFO_502 POINTER p502;


lpShare ="S h a r e d "; // LPWSTR
for dw=0 to StrLength(lpShare)
if(lpShare[dw]==" ") then
lpShare[dw]="\0";
endif;
endfor;

p502 = &s502;
level= 502;

mvarNET_API_STATUS = Netapi32.NetShareGetInfo(0, lpShare, level, p502);

return value is 0 - no error.
p502 gives memory allocation which I do not know how to decode it.
Labels (1)
0 Kudos
(2) Replies
MarkusLatz
Level 8

Take a look at installsite.org, there you find this code snippet:

http://www.installsite.org/files/NetShareRul.zip

regards

Markus
0 Kudos
Roman1
Level 9

Thanks. It helps!
0 Kudos