试试以下代码吧,手头上暂时没 XP ,但应没问题:
// uses clause:
uses ShellAPI, ShellExt
// declarations:
var
pszFileName: Pointer;
nIconIndex: DWORD;
// implementation:
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
GetMem(pszFileName, MAX_PATH*SizeOf(WideChar));
StringToWideChar('', pszFileName, MAX_PATH+1);
end
else
begin
GetMem(pszFileName, MAX_PATH*SizeOf(AnsiChar));
StrPCopy(pszFileName, '');
end;
nIconIndex := 0;
SHPickIcon(Handle, pszFileName, MAX_PATH, nIconIndex);
FreeMem(pszFileName);