Rev 95 | Rev 97 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 95 | Rev 96 | ||
---|---|---|---|
Line 378... | Line 378... | ||
378 | TGetVolumeNameForVolumeMountPoint = function(lpszVolumeMountPoint: LPCTSTR; lpszVolumeName: LPTSTR; cchBufferLength: DWORD): BOOL; stdcall; |
378 | TGetVolumeNameForVolumeMountPoint = function(lpszVolumeMountPoint: LPCTSTR; lpszVolumeName: LPTSTR; cchBufferLength: DWORD): BOOL; stdcall; |
379 | TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: LPCTSTR; dwFlags: DWORD): HRESULT; stdcall; |
379 | TSHEmptyRecycleBin = function(Wnd: HWND; pszRootPath: LPCTSTR; dwFlags: DWORD): HRESULT; stdcall; |
380 | TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall; |
380 | TSHGetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD); stdcall; |
381 | TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall; |
381 | TSHGetSetSettings = procedure(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL); stdcall; |
382 | 382 | ||
383 | type |
- | |
384 | TWideCharArray = array of WideChar; |
- | |
385 | TAnsiCharArray = array of AnsiChar; |
- | |
386 | - | ||
387 | function WideCharArrayToWideString(x: TWideCharArray): WideString; |
- | |
388 | var |
- | |
389 | i: integer; |
- | |
390 | begin |
- | |
391 | // In x86, the "cast" works with WideString. |
- | |
392 | // In x64, it does not work (outputs empty string, without compiler warning!) |
- | |
393 | // So, we created this fake-cast |
- | |
394 | SetLength(result, Length(x)); |
- | |
395 | for i := 0 to Length(x)-1 do |
- | |
396 | result[i+1] := x[i]; |
- | |
397 | end; |
- | |
398 | - | ||
399 | function AnsiCharArrayToWideString(x: TAnsiCharArray): WideString; |
- | |
400 | var |
- | |
401 | i: integer; |
- | |
402 | begin |
- | |
403 | SetLength(result, Length(x)); |
- | |
404 | for i := 0 to Length(x)-1 do |
- | |
405 | result[i+1] := WideChar(x[i]); |
- | |
406 | end; |
- | |
407 | - | ||
408 | procedure AnsiRemoveNulChars(var s: AnsiString); |
383 | procedure AnsiRemoveNulChars(var s: AnsiString); |
409 | begin |
384 | begin |
410 | while (Length(s) > 0) and (s[Length(s)] = #0) do |
385 | while (Length(s) > 0) and (s[Length(s)] = #0) do |
411 | s := Copy(s, 1, Length(s)-1); |
386 | s := Copy(s, 1, Length(s)-1); |
412 | end; |
387 | end; |
Line 1558... | Line 1533... | ||
1558 | 1533 | ||
1559 | procedure TRbVistaItem.ReadFromStream(stream: TStream); |
1534 | procedure TRbVistaItem.ReadFromStream(stream: TStream); |
1560 | var |
1535 | var |
1561 | r1: TRbVistaRecord1; |
1536 | r1: TRbVistaRecord1; |
1562 | r2: TRbVistaRecord2Head; |
1537 | r2: TRbVistaRecord2Head; |
1563 | r2SourceUnicode: TWideCharArray; |
1538 | r2SourceUnicode: array of WideChar; |
1564 | version: DWORD; |
1539 | version: DWORD; |
1565 | i: Integer; |
1540 | i: Integer; |
- | 1541 | resourcestring |
|
- | 1542 | LNG_VISTA_WRONG_FORMAT = 'Invalid Vista index format version %d'; |
|
1566 | begin |
1543 | begin |
1567 | stream.ReadBuffer(version, SizeOf(version)); |
1544 | stream.ReadBuffer(version, SizeOf(version)); |
1568 | 1545 | ||
1569 | if version = 1 then |
1546 | if version = 1 then |
1570 | begin |
1547 | begin |
Line 1592... | Line 1569... | ||
1592 | stream.ReadBuffer(r2, SizeOf(r2)); |
1569 | stream.ReadBuffer(r2, SizeOf(r2)); |
1593 | 1570 | ||
1594 | SetLength(r2SourceUnicode, SizeOf(WideChar)*(r2.SourceCountChars-1)); |
1571 | SetLength(r2SourceUnicode, SizeOf(WideChar)*(r2.SourceCountChars-1)); |
1595 | stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1)); |
1572 | stream.Read(r2SourceUnicode[0], SizeOf(WideChar)*(r2.sourceCountChars-1)); |
1596 | 1573 | ||
- | 1574 | // Invalid chars are automatically converted into '?' |
|
1597 | FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); // Invalid chars are automatically converted into '?' |
1575 | (* FSourceAnsi := AnsiString(WideCharArrayToWideString(r2sourceUnicode)); *) |
- | 1576 | SetLength(FSourceAnsi, Length(r2sourceUnicode)); |
|
- | 1577 | for i := 0 to Length(r2sourceUnicode)-1 do |
|
- | 1578 | FSourceAnsi[i+1] := AnsiChar(r2sourceUnicode[i]); |
|
- | 1579 | ||
1598 | FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode); |
1580 | (* FSourceUnicode := WideCharArrayToWideString(r2sourceUnicode); *) |
- | 1581 | SetLength(FSourceUnicode, Length(r2sourceUnicode)); |
|
- | 1582 | for i := 0 to Length(r2sourceUnicode)-1 do |
|
- | 1583 | FSourceUnicode[i+1] := WideChar(r2sourceUnicode[i]); |
|
- | 1584 | ||
1599 | FID := ''; // will be added manually (at the constructor) |
1585 | FID := ''; // will be added manually (at the constructor) |
1600 | FSourceDrive := AnsiChar(r2sourceUnicode[1]); |
1586 | FSourceDrive := AnsiChar(r2sourceUnicode[1]); |
1601 | FDeletionTime := FileTimeToDateTime(r2.deletionTime); |
1587 | FDeletionTime := FileTimeToDateTime(r2.deletionTime); |
1602 | FOriginalSize := r2.originalSize; |
1588 | FOriginalSize := r2.originalSize; |
1603 | end |
1589 | end |
1604 | else |
1590 | else |
1605 | begin |
1591 | begin |
1606 | raise Exception.CreateFmt('Invalid Vista index format version %d', [version]); |
1592 | raise Exception.CreateFmt(LNG_VISTA_WRONG_FORMAT, [version]); |
1607 | end; |
1593 | end; |
1608 | 1594 | ||
1609 | // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff) |
1595 | // Remove #0 at the end. There are some bugs where #0 is added to ANSI/Unicode read paths?! (probably in the ReadVista stuff) |
1610 | // TODO: Instead of using this workaround, fix "SourceUnicode" and "SourceAnsi" in the first place! |
1596 | // TODO: Instead of using this workaround, fix "SourceUnicode" and "SourceAnsi" in the first place! |
1611 | AnsiRemoveNulChars(FSourceAnsi); |
1597 | AnsiRemoveNulChars(FSourceAnsi); |