Hello.
I'am trying to mount a file (such as ZIP, encrypted file etc.) or a folder as a local drive (like SUBST). I thought i could work with SetVolumeMountPoint function, but i cannot pass a path to it directly i think. So i looked up some C example and found GetVolumeNameforVolumeMountPoint function. In C (WIN.H) it is declared as follwows:
BOOL WINAPI GetVolumeNameforVolumeMountPointA(LPCSTR,LPSTR,DWORD);
This is my implementation, but i does not compile (mismatch with prior definition): Any ideas?
I'am trying to mount a file (such as ZIP, encrypted file etc.) or a folder as a local drive (like SUBST). I thought i could work with SetVolumeMountPoint function, but i cannot pass a path to it directly i think. So i looked up some C example and found GetVolumeNameforVolumeMountPoint function. In C (WIN.H) it is declared as follwows:
BOOL WINAPI GetVolumeNameforVolumeMountPointA(LPCSTR,LPSTR,DWORD);
This is my implementation, but i does not compile (mismatch with prior definition): Any ideas?
Code:
#COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" DECLARE FUNCTION SetVolumeMountPoint LIB "KERNEL32.DLL" ALIAS "SetVolumeMountPointA" ( lpszVolumeMountPoint AS ASCIIZ, lpszVolumeName AS ASCIIZ ) AS DWORD DECLARE FUNCTION DeleteVolumeMountPoint LIB "KERNEL32.DLL" ALIAS "DeleteVolumeMountPointA" ( lpszVolumeMountPoint AS ASCIIZ ) AS DWORD DECLARE FUNCTION GetVolumeNameForVolumeMountPoint LIB "KERNEL32.DLL" ALIAS "GetVolumeNameForVolumeMountPointA" (lpszVolumeMountPoint AS ASCIIZ, lpszVolumeName AS ASCIIZ, cchBufferLength AS DWORD) AS DWORD '---------------------------------------------------------------------- ' Function SystemErrorMessageText ' deliver a text message for a given API-error number ' in error code by GetLastError() ' out error text '---------------------------------------------------------------------- FUNCTION SystemErrorMessageText (BYVAL ECode AS LONG) AS STRING LOCAL Buffer AS ASCIIZ * 255 LOCAL sText AS STRING FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, BYVAL %Null, ECode, %Null, buffer, SIZEOF(buffer), BYVAL %Null sText = FORMAT$(ECode, "##### ") & Buffer FUNCTION = TRIM$( sText ) END FUNCTION FUNCTION PBMAIN () AS LONG LOCAL Drv AS ASCIIZ * 30 LOCAL Path AS ASCIIZ * %Max_Path LOCAL lResult AS LONG Drv = "Y:\" 'Path= "\\?\T:\VMmachines\" Path= "T:\VMmachines\" lResult = SetVolumeMountPoint( Drv, Path ) 'lResult = SetVolumeMountPoint( Drv, Path ) IF lResult = 0 THEN lResult = GetLastError() MSGBOX "error "+SystemErrorMessageText(lResult) ELSE MSGBOX "Mount successful" lResult = DeleteVolumeMountPoint( Drv ) END IF END FUNCTION
Comment