Solved

Access my network

Posted on 1998-08-14
17
177 Views
Last Modified: 2010-04-04
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!!
0
Comment
Question by:bert1
  • 6
  • 6
  • 3
  • +2
17 Comments
 

Author Comment

by:bert1
ID: 1362111
Edited text of question
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362112
Hi bert1,

Q : what sort of network?

Zif.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362113
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...
0
 

Author Comment

by:bert1
ID: 1362114
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!
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362115
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;
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362116
I'll do if you don't like BlackMan's sources...
(I guess, you have at least Delphi 3?)
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362117
Sorry Madshi, I didn't see that you were working on some source...
0
 

Author Comment

by:bert1
ID: 1362118
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.


0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:bert1
ID: 1362119
I am using Delphi 4
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362120
What was you error? Check that Windows is in your Uses clause..
0
 

Author Comment

by:bert1
ID: 1362121
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...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362122
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...
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362123
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..
0
 

Author Comment

by:bert1
ID: 1362124
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!
0
 

Expert Comment

by:JimmyWhite
ID: 1362125
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.

 
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362126
Okay, Bert1, I can see that my cut'n'paste was to hard - I'll try to fix it..
0
 
LVL 7

Accepted Solution

by:
BlackMan earned 50 total points
ID: 1362127
Ok, here is a (new) cut from a working sample. It enumerates alle the servers in the WORKGROUP workgroup. If you want to enumerate a domain, just specify that domainname.
It then adds the servername to a listbox. If you want to enumerate the resources on the server, just call SCAN with the servername..


Var
  CurrentPlace : String;
  I : Integer;


type
  TNetRecArr = Array[0..9] of TNetResourceA;

procedure tform1.Scan(Name: String);
var
 Rec: TNetResourceA;
 Temp: TNetRecArr;
 NEHandle,
 NEResult,
 MaxRecs,
 BufSize: dword;
begin
  With Rec do
  begin
    dwScope:=RESOURCE_GLOBALNET;
    dwType:=RESOURCETYPE_DISK;
    dwDisplayType:=RESOURCEDISPLAYTYPE_SHARE;
    dwUsage:=0;
    lpLocalName:='';
    lpRemoteName:=PChar(Name);
    lpComment:='';
    lpProvider:='Microsoft Windows Network';
  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
        LB.Items.Add(Temp[I].lpremoteName);
      end;
    until NEResult<>NO_ERROR;
    if NEResult=ERROR_NO_MORE_ITEMS then
      WNetCloseEnum(NEHandle);
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Scan('WORKGROUP');
end;

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now