Lmoen
asked on
netsharecheck
can somebody please help me to use the "netsharecheck" function? What sort of values should I insert at the (LPTSTR) device value?
The little program I'm trying to write, is a program that displays to you which directories and devices are shared on your computer (and some other network-related functions). I think the "netsharecheck" function is the one to use for this situation.
An example would be appreciated
Thanks for *any* help
Lmoen
The little program I'm trying to write, is a program that displays to you which directories and devices are shared on your computer (and some other network-related functions). I think the "netsharecheck" function is the one to use for this situation.
An example would be appreciated
Thanks for *any* help
Lmoen
listen...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Lmoen,
as far as I understand, NetShareCheck is only for checking whether a specific device is shared. You can't use this for directories etc.
Furthermore you should know that the network APIs are *completely* different in winNT and win9x based systems. The names are sometimes the sames, but the parameters differ always.
If you want to have it the easy way (and if you have at least Delphi 4), you might want to try my package "madSecurity" (free for non-commercial use):
http://help.madshi.net/Data/madSecurity.htm
http://help.madshi.net/Data/Shares.htm
This package does what you need (at least if I understood your needs correctly) and works fine in both NT and 9x.
Regards, Madshi.
as far as I understand, NetShareCheck is only for checking whether a specific device is shared. You can't use this for directories etc.
Furthermore you should know that the network APIs are *completely* different in winNT and win9x based systems. The names are sometimes the sames, but the parameters differ always.
If you want to have it the easy way (and if you have at least Delphi 4), you might want to try my package "madSecurity" (free for non-commercial use):
http://help.madshi.net/Data/madSecurity.htm
http://help.madshi.net/Data/Shares.htm
This package does what you need (at least if I understood your needs correctly) and works fine in both NT and 9x.
Regards, Madshi.
BTW: If you want to locate shares on a remote machine look at
\\machinename\HKEY_LOCAL_M ACHINE\Sec urity\ACCE SS
Get a list of sub keys with RegEnumKey().
To do this RemoteAdmins must be installed on the remote machine and you must be part of the authorized group who can access the machine.
You can use the same method for your local machine if that is all you are interested in.
\\machinename\HKEY_LOCAL_M
Get a list of sub keys with RegEnumKey().
To do this RemoteAdmins must be installed on the remote machine and you must be part of the authorized group who can access the machine.
You can use the same method for your local machine if that is all you are interested in.
listening....
ASKER
please check my usage, I still can't get it to work, and I don't know what value the LPDWORD variable should be...?
The help file says the following, but I don't know how to get the adress, and i.e implement this =>
(Pointer to an address that contains the type of device share. On return the address pointed to by the type parameter contains the type of share the device is offered with. This parameter is set only if the function returned successfully.)
var
temp : LPDWORD;
begin
temp := ???????
NetShareCheck(NULL, 'Canon Bubble-Jet BJC-600', temp);
end;
(Canon is the printer I have)
Thanks for the help, again
Lmoen
The help file says the following, but I don't know how to get the adress, and i.e implement this =>
(Pointer to an address that contains the type of device share. On return the address pointed to by the type parameter contains the type of share the device is offered with. This parameter is set only if the function returned successfully.)
var
temp : LPDWORD;
begin
temp := ???????
NetShareCheck(NULL, 'Canon Bubble-Jet BJC-600', temp);
end;
(Canon is the printer I have)
Thanks for the help, again
Lmoen
Documentation indicates that netsharecheck is obsolete. It is a ported LAN Manager Function.....
Here is some code you can try:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, toolwin;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
var
dwResult,dwResultEnum : DWORD;
lpnr : PNetResourceA;
cbBuffer : DWORD;
cEntries : DWord;
ListRes : String;
nr : PNETRESOURCEA;
hEnum, lpcCount: Cardinal;
lpBuff: longInt;
s : String;
p, CCount : LongInt;
i: integer;
begin
//lpcCount := 0xFFFFFFFF;
cbBuffer := 16384;
CCount := $FFFFFFFF;
nr.dwUsage := RESOURCEUSAGE_CONTAINER;
nr.lpRemoteName := 0;
dwResult := WNetOpenEnum(RESOURCE_GLOB ALNET, RESOURCETYPE_ANY,0,nr,hEnu m);
//
if dwResult = NO_ERROR then
begin
lpBuff := GLOBALALLOC(GPTR,cbBuffer) ;
dwResultEnum := WNetEnumResource(hEnum, cEntries, nr, cbBuffer);
p := p + length(nr.lpRemotename);
SetLength(s,p);
s := PChar(nr.lpRemoteName);
ListBox1.Items.Add(IntToSt r(p));
end;
end;
end.
Good Luck.
Here is some code you can try:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, toolwin;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
dwResult,dwResultEnum : DWORD;
lpnr : PNetResourceA;
cbBuffer : DWORD;
cEntries : DWord;
ListRes : String;
nr : PNETRESOURCEA;
hEnum, lpcCount: Cardinal;
lpBuff: longInt;
s : String;
p, CCount : LongInt;
i: integer;
begin
//lpcCount := 0xFFFFFFFF;
cbBuffer := 16384;
CCount := $FFFFFFFF;
nr.dwUsage := RESOURCEUSAGE_CONTAINER;
nr.lpRemoteName := 0;
dwResult := WNetOpenEnum(RESOURCE_GLOB
//
if dwResult = NO_ERROR then
begin
lpBuff := GLOBALALLOC(GPTR,cbBuffer)
dwResultEnum := WNetEnumResource(hEnum, cEntries, nr, cbBuffer);
p := p + length(nr.lpRemotename);
SetLength(s,p);
s := PChar(nr.lpRemoteName);
ListBox1.Items.Add(IntToSt
end;
end;
end.
Good Luck.
oops...
ListBox1.Items.Add(s);
ListBox1.Items.Add(s);