Solved

lanmanager api example(s) wanted

Posted on 2002-06-16
3
173 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi parse string to params 3 177
Delphi Yen format 3 72
I want to use librsync in my Delphi backup application. 3 84
MS Access from Delphi 31 100
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…

734 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