Solved

Testing Novell mapping to driveletter

Posted on 1998-06-18
4
273 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
Comment Utility
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
Comment Utility
rember to add FileCtrl to your uses clause
0
 
LVL 1

Expert Comment

by:Greedy
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now