Link to home
Start Free TrialLog in
Avatar of bert1
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!!
Avatar of bert1
bert1

ASKER

Edited text of question
Hi bert1,

Q : what sort of network?

Zif.
Look at the IShellFolder interface.

(1) Use SHGetSpecialFolderLocation(0,CSIDL_NETWORK,pidl)
(2) Use SHGetDesktopFolder(myDesktopFolderInterface)
(3) Use myDesktopFolderInterface.BindToObject to bind it to the pidl you receive from (1)
(4) Use myDesktopFolderInterface.EnumObjects to enumerate the content of the network neighborhood

Hope this helps...
Avatar of bert1

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!
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_GLOBALNET;
    dwType:=RESOURCETYPE_DISK;
    dwDisplayType:=0;
    dwUsage:=0;
    lpLocalName:='';
    lpRemoteName:=PChar(Name)
    lpComment:='';
    lpProvider:='';
  End;
  CurrentPlace:='';
  NEResult:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK,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,Temp,BufSize);
      if (NEResult=NO_ERROR) or (NEResult=ERROR_NO_MORE_ITEMS) then
      begin
        For I:=0 to MaxRecs-1 do
          DoSomething(Temp[I]);
      end;
    until NEResult<>NO_ERROR;
    if NEResult=ERROR_NO_MORE_ITEMS then
      WNetCloseEnum(NEHandle);
  end;
end;
I'll do if you don't like BlackMan's sources...
(I guess, you have at least Delphi 3?)
Sorry Madshi, I didn't see that you were working on some source...
Avatar of bert1

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.


Avatar of bert1

ASKER

I am using Delphi 4
What was you error? Check that Windows is in your Uses clause..
Avatar of bert1

ASKER

NEResult:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK,0,@Rec,NEHandle);

NEResult:=WNetEnumResource(NEHandle,MaxRecs,Temp,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...
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 guess you are right about the D4 issue. Try to declare the variables NEHandle, MAxRecs, BufSize as DWORD, I think that will help..
Avatar of bert1

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!
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.

 
Okay, Bert1, I can see that my cut'n'paste was to hard - I'll try to fix it..
ASKER CERTIFIED SOLUTION
Avatar of BlackMan
BlackMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial