Solved

ChDrive and Network Drives

Posted on 1998-05-08
5
532 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

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
By default, Carbonite Server Backup manages your encryption key for you using Advanced Encryption Standard (AES) 128-bit encryption. If you choose to manage your private encryption key, your backups will be encrypted using AES 256-bit encryption.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

863 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

23 Experts available now in Live!

Get 1:1 Help Now