Solved

ChDrive and Network Drives

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
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 lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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