bert1
asked on
Access my network
How do I do to access my network and list the computers that are on the global network, and if theres shared files , list them too in a file.
Thanks!!
Thanks!!
Hi bert1,
Q : what sort of network?
Zif.
Q : what sort of network?
Zif.
Look at the IShellFolder interface.
(1) Use SHGetSpecialFolderLocation (0,CSIDL_N ETWORK,pid l)
(2) Use SHGetDesktopFolder(myDeskt opFolderIn terface)
(3) Use myDesktopFolderInterface.B indToObjec t to bind it to the pidl you receive from (1)
(4) Use myDesktopFolderInterface.E numObjects to enumerate the content of the network neighborhood
Hope this helps...
(1) Use SHGetSpecialFolderLocation
(2) Use SHGetDesktopFolder(myDeskt
(3) Use myDesktopFolderInterface.B
(4) Use myDesktopFolderInterface.E
Hope this helps...
ASKER
Madshi, can you give me an example of code, that should work to run, and write some comments to it... I´m new in Delphi :o)
I didn´t find information about the IShellFolder interface.
Thanks!
I didn´t find information about the IShellFolder interface.
Thanks!
Try this...
type
TNetRecArr: Array[0..9] of TNetResourceA;
procedure Scan(Name: String);
var
Rec: TNetResourceA;
Temp: TNetRecArr;
NEHandle: Integer;
NEResult: Integer;
MaxRecs: Integer;
BufSize: Integer;
begin
With Rec do
begin
dwScope:=RESOURCE_GLOBALNE T;
dwType:=RESOURCETYPE_DISK;
dwDisplayType:=0;
dwUsage:=0;
lpLocalName:='';
lpRemoteName:=PChar(Name)
lpComment:='';
lpProvider:='';
End;
CurrentPlace:='';
NEResult:=WNetOpenEnum(RES OURCE_GLOB ALNET,RESO URCETYPE_D ISK,0,@Rec ,NEHandle) ;
{ Open enumeration, all resources, only disk, and no printers }
if NEResult=0 then
begin
BufSize:=SizeOf(Temp);
repeat
MaxRecs:=10;
NEResult:=WNetEnumResource (NEHandle, MaxRecs,Te mp,BufSize );
if (NEResult=NO_ERROR) or (NEResult=ERROR_NO_MORE_IT EMS) then
begin
For I:=0 to MaxRecs-1 do
DoSomething(Temp[I]);
end;
until NEResult<>NO_ERROR;
if NEResult=ERROR_NO_MORE_ITE MS then
WNetCloseEnum(NEHandle);
end;
end;
type
TNetRecArr: Array[0..9] of TNetResourceA;
procedure Scan(Name: String);
var
Rec: TNetResourceA;
Temp: TNetRecArr;
NEHandle: Integer;
NEResult: Integer;
MaxRecs: Integer;
BufSize: Integer;
begin
With Rec do
begin
dwScope:=RESOURCE_GLOBALNE
dwType:=RESOURCETYPE_DISK;
dwDisplayType:=0;
dwUsage:=0;
lpLocalName:='';
lpRemoteName:=PChar(Name)
lpComment:='';
lpProvider:='';
End;
CurrentPlace:='';
NEResult:=WNetOpenEnum(RES
{ Open enumeration, all resources, only disk, and no printers }
if NEResult=0 then
begin
BufSize:=SizeOf(Temp);
repeat
MaxRecs:=10;
NEResult:=WNetEnumResource
if (NEResult=NO_ERROR) or (NEResult=ERROR_NO_MORE_IT
begin
For I:=0 to MaxRecs-1 do
DoSomething(Temp[I]);
end;
until NEResult<>NO_ERROR;
if NEResult=ERROR_NO_MORE_ITE
WNetCloseEnum(NEHandle);
end;
end;
I'll do if you don't like BlackMan's sources...
(I guess, you have at least Delphi 3?)
(I guess, you have at least Delphi 3?)
Sorry Madshi, I didn't see that you were working on some source...
ASKER
There where some errors in that code, BalckMan.
Did you try it so it worked for you?
I didnt get it to work...
Madshi if you have a suggestion an example... that works, you are welcome.
Did you try it so it worked for you?
I didnt get it to work...
Madshi if you have a suggestion an example... that works, you are welcome.
ASKER
I am using Delphi 4
What was you error? Check that Windows is in your Uses clause..
ASKER
NEResult:=WNetOpenEnum(RES OURCE_GLOB ALNET,RESO URCETYPE_D ISK,0,@Rec ,NEHandle) ;
NEResult:=WNetEnumResource (NEHandle, MaxRecs,Te mp,BufSize );
The error was:
"Types of actual and formal var parameters must be identical"
I think it can have something to do with Delphi 4...
NEResult:=WNetEnumResource
The error was:
"Types of actual and formal var parameters must be identical"
I think it can have something to do with Delphi 4...
BlackMan, doesn't matter, my suggestion does not work anyhow... :-(
Bert1, I'm sorry, I tested my own suggestion: It seems, that it can enumerate every little file/dir/object/whatever of the whole windows system, but unfortunately not the network neighborhood. Don't know why. Oooh, Bill...
Bert1, I'm sorry, I tested my own suggestion: It seems, that it can enumerate every little file/dir/object/whatever of the whole windows system, but unfortunately not the network neighborhood. Don't know why. Oooh, Bill...
Bert1, I guess you are right about the D4 issue. Try to declare the variables NEHandle, MAxRecs, BufSize as DWORD, I think that will help..
ASKER
BlackMan, say I will save the computers name (lpLocalName) that are connected to the network in ListBox1 when I press on Button1, with my computer name Bert.
That helped with DWORD... But can you check so you get it working yourself first... and then give me the code... cause I didn´t get it to work with the Scan procedure.
Then it should work for me
Thanks for your help!
That helped with DWORD... But can you check so you get it working yourself first... and then give me the code... cause I didn´t get it to work with the Scan procedure.
Then it should work for me
Thanks for your help!
What kind of network is it ? If it is Novell 4.xx you can download some activex components from Novell which will do almost everything you want. But be carefull because
they also can delete items from the NDS.
they also can delete items from the NDS.
Okay, Bert1, I can see that my cut'n'paste was to hard - I'll try to fix it..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER