Rev 90 | Rev 95 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 90 | Rev 93 | ||
---|---|---|---|
Line 64... | Line 64... | ||
64 | EAPICallError = class(Exception); |
64 | EAPICallError = class(Exception); |
65 | EEventCategoryNotDefined = class(Exception); |
65 | EEventCategoryNotDefined = class(Exception); |
66 | EInvalidDrive = class(Exception); |
66 | EInvalidDrive = class(Exception); |
67 | 67 | ||
68 | PSHQueryRBInfo = ^TSHQueryRBInfo; |
68 | PSHQueryRBInfo = ^TSHQueryRBInfo; |
- | 69 | {$IFDEF WIN64} |
|
- | 70 | // ATTENTION! MUST NOT BE PACKED! Alignment for 64 bit must be 8 and for 32 bit must be 4 |
|
- | 71 | TSHQueryRBInfo = record |
|
- | 72 | {$ELSE} |
|
69 | TSHQueryRBInfo = packed record |
73 | TSHQueryRBInfo = packed record |
- | 74 | {$ENDIF} |
|
70 | cbSize : DWORD; |
75 | cbSize : DWORD; |
71 | i64Size : int64; |
76 | i64Size : int64; |
72 | i64NumItems : int64; |
77 | i64NumItems : int64; |
73 | end; |
78 | end; |
74 | 79 | ||
Line 354... | Line 359... | ||
354 | LNG_FILE_NOT_FOUND = 'File not found: %s'; |
359 | LNG_FILE_NOT_FOUND = 'File not found: %s'; |
355 | LNG_INVALID_INFO_FORMAT = 'Unexpected record size: %s'; |
360 | LNG_INVALID_INFO_FORMAT = 'Unexpected record size: %s'; |
356 | LNG_DRIVE_NOT_EXISTING = 'Drive %s does not exist.'; |
361 | LNG_DRIVE_NOT_EXISTING = 'Drive %s does not exist.'; |
357 | 362 | ||
358 | const |
363 | const |
- | 364 | {$IFDEF UNICODE} |
|
- | 365 | C_SHEmptyRecycleBin = 'SHEmptyRecycleBinW'; |
|
- | 366 | C_SHQueryRecycleBin = 'SHQueryRecycleBinW'; |
|
- | 367 | C_GetVolumeNameForVolumeMountPoint = 'GetVolumeNameForVolumeMountPointW'; |
|
- | 368 | {$ELSE} |
|
- | 369 | C_SHEmptyRecycleBin = 'SHEmptyRecycleBinA'; |
|
359 | C_SHQueryRecycleBin = 'SHQueryRecycleBinA'; |
370 | C_SHQueryRecycleBin = 'SHQueryRecycleBinA'; |
360 | C_GetVolumeNameForVolumeMountPoint = 'GetVolumeNameForVolumeMountPointA'; |
371 | C_GetVolumeNameForVolumeMountPoint = 'GetVolumeNameForVolumeMountPointA'; |
361 | C_SHEmptyRecycleBinA = 'SHEmptyRecycleBinA'; |
372 | {$ENDIF} |
362 | C_SHGetSettings = 'SHGetSettings'; |
373 | C_SHGetSettings = 'SHGetSettings'; |
363 | C_SHGetSetSettings = 'SHGetSetSettings'; |
374 | C_SHGetSetSettings = 'SHGetSetSettings'; |
364 | 375 | ||
365 | type |
376 | type |
366 | TSHQueryRecycleBin = function(pszRootPath: LPCTSTR; var pSHQueryRBInfo: TSHQueryRBInfo): HRESULT; stdcall; |
377 | TSHQueryRecycleBin = function(pszRootPath: LPCTSTR; var pSHQueryRBInfo: TSHQueryRBInfo): HRESULT; stdcall; |
367 | TGetVolumeNameForVolumeMountPointA = function(lpszVolumeMountPoint: LPCSTR; lpszVolumeName: LPSTR; cchBufferLength: DWORD): BOOL; stdcall; |
378 | TGetVolumeNameForVolumeMountPoint = function(lpszVolumeMountPoint: LPCTSTR; lpszVolumeName: LPTSTR; cchBufferLength: DWORD): BOOL; stdcall; |
368 | TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: PChar; dwFlags: DWORD): HRESULT; stdcall; |
379 | TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: LPCTSTR; dwFlags: DWORD): HRESULT; stdcall; |
369 | TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall; |
380 | TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall; |
370 | TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall; |
381 | TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall; |
371 | 382 | ||
372 | function WideCharArrayToWideString(x: array of WideChar): WideString; |
383 | function WideCharArrayToWideString(x: array of WideChar): WideString; |
373 | var |
384 | var |
Line 402... | Line 413... | ||
402 | s := Copy(s, 1, Length(s)-1); |
413 | s := Copy(s, 1, Length(s)-1); |
403 | end; |
414 | end; |
404 | 415 | ||
405 | function GetDriveGUID(driveLetter: AnsiChar; var guid: TGUID): DWORD; |
416 | function GetDriveGUID(driveLetter: AnsiChar; var guid: TGUID): DWORD; |
406 | var |
417 | var |
407 | Buffer: array[0..50] of AnsiChar; |
418 | Buffer: array[0..50] of Char; |
408 | x: string; |
419 | x: string; |
409 | PGetVolumeNameForVolumeMountPointA: TGetVolumeNameForVolumeMountPointA; |
420 | PGetVolumeNameForVolumeMountPoint: TGetVolumeNameForVolumeMountPoint; |
410 | RBHandle: THandle; |
421 | RBHandle: THandle; |
411 | begin |
422 | begin |
412 | RBHandle := LoadLibrary(kernel32); |
423 | RBHandle := LoadLibrary(kernel32); |
413 | try |
424 | try |
414 | if RBHandle <> 0 then |
425 | if RBHandle <> 0 then |
415 | begin |
426 | begin |
416 | PGetVolumeNameForVolumeMountPointA := GetProcAddress(RBHandle, C_GetVolumeNameForVolumeMountPoint); |
427 | PGetVolumeNameForVolumeMountPoint := GetProcAddress(RBHandle, C_GetVolumeNameForVolumeMountPoint); |
417 | if not Assigned(@PGetVolumeNameForVolumeMountPointA) then |
428 | if not Assigned(@PGetVolumeNameForVolumeMountPoint) then |
418 | begin |
429 | begin |
419 | result := GetLastError; |
430 | result := GetLastError; |
420 | FreeLibrary(RBHandle); |
431 | FreeLibrary(RBHandle); |
421 | RBHandle := 0; |
432 | RBHandle := 0; |
422 | end |
433 | end |
423 | else |
434 | else |
424 | begin |
435 | begin |
425 | if PGetVolumeNameForVolumeMountPointA(PAnsiChar(AnsiString(driveLetter+':\')), Buffer, SizeOf(Buffer)) then |
436 | if PGetVolumeNameForVolumeMountPoint(PChar(driveLetter+':\'), Buffer, SizeOf(Buffer)) then |
426 | begin |
437 | begin |
427 | x := string(buffer); |
438 | x := string(buffer); |
428 | x := copy(x, 11, 38); |
439 | x := copy(x, 11, 38); |
429 | guid := StringToGUID(x); |
440 | guid := StringToGUID(x); |
430 | result := ERROR_SUCCESS; |
441 | result := ERROR_SUCCESS; |
Line 1618... | Line 1629... | ||
1618 | result := true; |
1629 | result := true; |
1619 | LibHandle := LoadLibrary(shell32); |
1630 | LibHandle := LoadLibrary(shell32); |
1620 | try |
1631 | try |
1621 | if LibHandle <> 0 then |
1632 | if LibHandle <> 0 then |
1622 | begin |
1633 | begin |
1623 | @PSHEmptyRecycleBin := GetProcAddress(LibHandle, C_SHEmptyRecycleBinA); |
1634 | @PSHEmptyRecycleBin := GetProcAddress(LibHandle, C_SHEmptyRecycleBin); |
1624 | if @PSHEmptyRecycleBin <> nil then |
1635 | if @PSHEmptyRecycleBin <> nil then |
1625 | begin |
1636 | begin |
1626 | PSHEmptyRecycleBin(hInstance, nil, flags); |
1637 | PSHEmptyRecycleBin(hInstance, nil, flags); |
1627 | end |
1638 | end |
1628 | else |
1639 | else |