Solved

Testing Novell mapping to driveletter

Posted on 1998-06-18
4
284 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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