PathGetDriveNumberPathGetDriveNumber*
*Contents  *Index  *Topic Contents
*Previous Topic: PathGetCharType
*Next Topic: PathIsContentType

PathGetDriveNumber


int PathGetDriveNumber(
    LPCTSTR lpsz
    );

Searches a path for a drive letter within the range of 'A' to 'Z' and returns the corresponding drive number.

lpsz
Address of a string that contains the path to be searched.

Example:

#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main( void )
{
	// Paths to search for drive IDs.
	char buffer_1[] = "A:\\TEST\\bar.txt"; 
	char *lpStr1;
	lpStr1 = buffer_1;

	char buffer_2[] = "B:\\TEST\\bar.txt"; 
	char *lpStr2;
	lpStr2 = buffer_2;

	char buffer_3[] = "Z:\\TEST\\bar.txt"; 
	char *lpStr3;
	lpStr3 = buffer_3;

	char buffer_4[] = "%:\\TEST\\bar.txt"; 
	char *lpStr4;
	lpStr4 = buffer_4;

cout << "The path passed to the function was  : " << lpStr1 <<
        "\nThe path contains a drive identifier : " << PathGetDriveNumber(lpStr1) << endl;

cout << "The path passed to the function was  : " << lpStr2 <<
        "\nThe path contains a drive identifier : " << PathGetDriveNumber(lpStr2) << endl;

cout << "The path passed to the function was  : " << lpStr3 <<
        "\nThe path contains a drive identifier : " << PathGetDriveNumber(lpStr3) << endl;

cout << "The path passed to the function was  : " << lpStr4 <<
        "\nThe path contains a drive identifier : " << PathGetDriveNumber(lpStr4) << endl;
}
OUTPUT:
===========
The path passed to the function was  : A:\TEST\bar.txt
The path contains a drive identifier : 0
The path passed to the function was  : B:\TEST\bar.txt
The path contains a drive identifier : 1
The path passed to the function was  : Z:\TEST\bar.txt
The path contains a drive identifier : 25
The path passed to the function was  : %:\TEST\bar.txt
The path contains a drive identifier : -1

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.