Solved

Testing Novell mapping to driveletter

Posted on 1998-06-18
4
281 Views
Last Modified: 2012-05-04
I would like to have a Delphi procedure for testing the existence of
a drivemapping under NT 4.0 Workstation SP 3, running the Novell Intranetware Client,
on a Novell 4.11 server when the NT 4.0 Workstation does a NDS logon.

Something with the functionality of this procedure will be OK.
I use Delphi 3.0 Standard Edition.

Function ISMAPPING (testdrive: string; testUNC: string; SERVERVOLUMEDIRSUBDIR: string; ROOT: boolean)
begin
if ROOT then
   *is  testDrive rootmapped to  SERVERVOLUMEDIRSUBDIR
   *YES ISMAPPING:=TRUE;
   *NO   ISMAPPING:=FALSE:
else
   *is testDrive mapped to testUNC
   *YES ISMAPPING:=TRUE;
   *NO   ISMAPPING:=FALSE:

end;

Please provide a functional procedure.
0
Comment
Question by:mosi
  • 3
4 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1353685
humm...I'm not sure if you can test if the drive is maped to a novell system or another exported network drive but if you know the name of the novell box you could do this

  Integer(DriveBits) := GetLogicalDrives;
  For DriveNum := 0 to 25 do
  begin
    if not (DriveNum in DriveBits) then Continue;
    begin
      DriveChar := Char(DriveNum + Ord('a'));
      if FileCtrl.TDriveType(GetDriveType(PChar(DriveChar + ':\'))) in [FileCtrl.dtNetwork] then
      begin
        MyServerString := ExpandUNCFileName(DriveChar + '\.');
        <then see if your novel server's name is in the MyServerString using the POS() function>
      end;

I'm going to write a quick test to see if this really works :)
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1353686
rember to add FileCtrl to your uses clause
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1353687
This is the unit to the sample program is seams to do everything just the way I planed.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  DriveNum : Integer;
  DriveBits : set of 0..25;
  DriveChar : Char;

begin
  Integer(DriveBits) := GetLogicalDrives;
  For DriveNum := 0 to 25 do
  begin
    if not (DriveNum in DriveBits) then Continue;
    begin
      DriveChar := Char(DriveNum + Ord('a'));
      if FileCtrl.TDriveType(GetDriveType(PChar(DriveChar + ':\'))) in [FileCtrl.dtNetwork] then
        ListBox1.Items.Add(ExpandUNCFileName(DriveChar + ':\.'));
    end;
  end;
end;

end.

0
 

Accepted Solution

by:
rhale earned 300 total points
ID: 1353688
A Couple of Options for you:

1.  Using Only regular API Calls.  (Works for NT and NetWare)
2.  Using Novell specific NWSIPX32 calls, i.e. client32 required.

Using 1:  

Check to see if the network is loaded:
     if not (GetSystemMetrics(SM_NETWORK) AND $01 = $01) then Exit;

Check to see if a drive letter is available:
     if not IsDriveReady('F') then Exit;
 

//code for IsDriveReady:
//You would need to modify this to suit you preference on path, etc
function TForm.IsDriveReady(DriveLetter : char) : bool;
var
  OldErrorMode : Word;
  OldDirectory : string;
begin
try
  OldErrorMode := SetErrorMode(SEM_NOOPENFILEERRORBOX);
  GetDir(0, OldDirectory);
{$I-}
  ChDir(DriveLetter + ':\');
{$I+}
  if IoResult <> 0 then
    Result := False
  else
    Result := True;

  ChDir(OldDirectory);
  SetErrorMode(OldErrorMode);
except
      on E:Exception do
         Result:=False;
end;
end;//IsDriveReady

2. Using NetWare specific code, calling into CALWIN32.DLL
//You will need to include nwsipx32 and calwin32 for this function
//Download the Delphi Netware shim from devsup.novell.com
//See also http://developer.novell.com/engsup/sample/areas/delphis.htm
//if you can't find either of these, email me at rhale@poboxes.com

procedure TForm.GetMap;
var
  i, status: Integer;
  conn:NWCONN_HANDLE;
  rootpath:array [0..256] of char;
  relativePath: array [0..256] of char;
  fullPath: array [0..256] of char;
  driveltr: string;
  ccode:integer;
begin
  NWCallsInit(nil,nil);
 {get the current drive status for A..Z}
  ListBox1.Items.Clear;
  for i:=1 to 26 do
  begin
    fillchar(fullpath,257,#0);
    ccode:=NWGetDriveStatus(
      { > drive Number    }  i,
      { > path format     }  NW_FORMAT_SERVER_VOLUME, //gets both server and volume
      { < bitmask pointer }  @status,
      { < conn Handle     }  conn,
      { < root path       }  @rootPath,
      { < relative path   }  @relativePath,
      { < full path       }  @fullPath);
    if (ccode<0)then
    begin
       ShowMessage('NWGetDriveStatus Failed'+#13+'Error Code: '+inttostr(ccode));
       exit;
    end;

    driveltr:=inttochar(i);
    ListBox1.Items.Add(driveltr+': '+strpas(fullPath));
  end;
end;//GetMap


0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: Connect to running MS Outlook 4 95
Delphi and Access based Enumeration 9 64
Graphics32 under Delphi 10.1 Berlin 2 69
enhance the following code 3 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

825 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