1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
| function TForm1.pfadbuchstabezuweisen(Ziellwb:string; namedesusblaufwerk:string):boolean; type tmountname = function(ziellwb:string; volumename:string; buffer:dword):boolean;stdcall; taction = function(ziellwb:string; volumename:string):boolean;stdcall; var dlllibrary : THandle; setvolumemountpoint : taction; volumename : array[0..1000] of char; getvolumenamemountpoint : tmountname; begin result := false; result := DefineDosDevice(DDD_RAW_TARGET_PATH,pchar(ziellwb),pchar(namedesusblaufwerk)); dlllibrary := LoadLibrary('Kernel32.dll'); @getvolumenamemountpoint := GetProcAddress(dlllibrary,'GetVolumeNameForVolumeMountPointA'); if @getvolumenamemountpoint <> nil then begin Result := getvolumenamemountpoint(Ziellwb,volumename,MAX_PATH); if (not getvolumenamemountpoint(pchar(Ziellwb),volumename,MAX_PATH)) then volumename[0] := #0;
result := DefineDosDevice(DDD_RAW_TARGET_PATH or DDD_EXACT_MATCH_ON_REMOVE or DDD_EXACT_MATCH_ON_REMOVE,pchar(ziellwb),pchar(namedesusblaufwerk) ); end;
@SetVolumeMountPoint := GetProcAddress(dlllibrary,'SetVolumeMountPointA'); setvolumemountpoint(Pchar(Ziellwb),volumename);
if @setvolumemountpoint <> nil then result := setvolumemountpoint(Pchar(Ziellwb),volumename);
FreeLibrary(dlllibrary); end; |