Solved

Testing Novell mapping to driveletter

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month5 days, 23 hours left to enroll

627 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