Solved

ChDrive and Network Drives

Posted on 1998-05-08
5
545 Views
Last Modified: 2013-11-15
How can you change to a network drive?

The Chdrive function only works for mapped drives (e.g. single letter names a: c: etc)

How can I achieve this for a drive beginning \\machineName\sys for example?
0
Comment
Question by:microdrainage
5 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1444045
As you said the Chdrive only works with drive letters.
The only way two ways is using api or mapping drives(one for each machine name.)

Sorry if ican help you more
0
 

Author Comment

by:microdrainage
ID: 1444046
Does anybody know an API call to do this?

My overall aim is to find the amount of free drive space.
Unfortunately the DiskSpaceFree() function (from VB5STKIT.DLL) can only check the current drive and therefore the need for ChDrive or an equivalent.

Can anybody help?

0
 

Expert Comment

by:TheGun
ID: 1444047
I am currently working on a network type of application. Have you ever used run across the Win32 API for VB by Dan Appleman? If so there is a chapter that is included on cd that demostrates how to use the network APIs. In his example he takes a UNC and maps a drive/ makes a connection. Is this similar to what you are looking to do?


0
 
LVL 7

Accepted Solution

by:
tward earned 100 total points
ID: 1444048
I believe this function will take a UNC name, if not let me know there is another function that I can look into:

Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long

The C/C++ Definition:

The GetDiskFreeSpace function retrieves information about the specified disk, including the amount of free space on the disk.
BOOL GetDiskFreeSpace(
    LPCTSTR lpRootPathName,      // address of root path
    LPDWORD lpSectorsPerCluster,      // address of sectors per cluster
    LPDWORD lpBytesPerSector,      // address of bytes per sector
    LPDWORD lpNumberOfFreeClusters,      // address of number of free clusters  
    LPDWORD lpTotalNumberOfClusters       // address of total number of clusters  
   );      
 
Parameters
lpRootPathName
Points to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory.
lpSectorsPerCluster
Points to a variable for the number of sectors per cluster.
lpBytesPerSector
Points to a variable for the number of bytes per sector.
lpNumberOfFreeClusters
Points to a variable for the total number of free clusters on the disk.
lpTotalNumberOfClusters
Points to a variable for the total number of clusters on the disk.
 
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
See Also
GetDriveType

0
 

Author Comment

by:microdrainage
ID: 1444049
Cheers!! This solves the problem! We are off to buy the API guide!!!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

733 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