Solved

Testing Novell mapping to driveletter

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

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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