Solved

lanmanager api example(s) wanted

Posted on 2002-06-16
3
172 Views
Last Modified: 2010-04-04
just wondering if anyone has any examples to do with connecting to a remote share with NetShareAdd and/or enumerating remote shares with NetShareEnum. thanks.
0
Comment
Question by:freedumb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 100 total points
ID: 7082044
HI, freedumb,
I found in my projects (don't forget from where) something that maybe is of any use and interest for you.
Here it is:

unit frmMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  PSILnch, StdCtrls, ImgList;

type
  TFormMain = class(TForm)
    Button3: TButton;
    Memo1: TMemo;
    procedure Button3Click(Sender: TObject);
  private
    function EnumerateFunc(hwnd: HWND; hdc: HDC;
      lpnr: PNetResource): Boolean;
    { Private declarations }
  public
    a: longint;
    procedure TestWndProc(var Message: TMessage);
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation

{$R *.DFM}


procedure TFormMain.TestWndProc(var Message: TMessage);
begin
end;

function TFormMain.EnumerateFunc( hwnd: HWND; hdc: HDC ; lpnr: PNetResource ): Boolean;
const
  cbBuffer : DWORD  = 16384;      // 16K is a good size
var
  hEnum, dwResult, dwResultEnum : DWORD;
  lpnrLocal : array
        [0..16384 div SizeOf(TNetResource)] of TNetResource;    // pointer to enumerated structures
  i : integer;
  cEntries : Longint;
begin
  centries := -1;    // enumerate all possible entries

  // Call the WNetOpenEnum function to begin the enumeration.
  dwResult := WNetOpenEnum(
                          RESOURCE_CONTEXT,  // Enumerate currently connected resources.
                          RESOURCETYPE_DISK, // all resources
                          0,                 // enumerate all resources
                          lpnr,              // NULL first time the function is called
                          hEnum              // handle to the resource
                          );

  if (dwResult <> NO_ERROR) then
  begin
    // Process errors with an application-defined error handler
    Result := False;
    Exit;
  end;

  // Initialize the buffer.
  FillChar( lpnrLocal, cbBuffer, 0 );

  // Call the WNetEnumResource function to continue
  //  the enumeration.
  dwResultEnum := WNetEnumResource(hEnum, // resource handle
                                  DWORD(cEntries),
 // defined locally as -1
                                  @lpnrLocal,
// LPNETRESOURCE
                                  cbBuffer); // buffer size

  // This is just printing
  for i := 0 to cEntries - 1 do
  begin
    // loop through each structure and
    // get remote name of resource... lpnrLocal[i].lpRemoteName)
    Memo1.Lines.Add(lpnrLocal[i].lpRemoteName);
  end;

  // Call WNetCloseEnum to end the enumeration.
  dwResult := WNetCloseEnum(hEnum);

  if(dwResult <> NO_ERROR) then
  begin
    // Process errors... some user defined function here
    Result := False;
  end
  else
    Result :=  True;
end;

procedure TFormMain.Button3Click(Sender: TObject);
var  wnd: HWND;
      dc: HDC ;
     lpnr: PNetResource;
begin
 lpnr:=NIL;
 EnumerateFunc(wnd, dc, lpnr);
end;

end.

Sincerely,
Nestorua.
0
 

Expert Comment

by:CleanupPing
ID: 9343198
freedumb:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9453374
freedumb,
No comment has been added lately (17 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to nestorua http:#7082044

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 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