非常感谢大家的关注!!!不过还是期盼着高手的到来!!! (200分)

  • 主题发起人 主题发起人 HD_Copy
  • 开始时间 开始时间
我是在windows xp +delphi5下,一点问题都没有。
你让我Email给你,你的Email在哪里啊?
 
WINGDOW98,没问题?
 
已经Email给你了。
刚才我一同事在win2000下试了,不认识的的确显示不出来。但xp下没问题。
 


既然和效果我一样的同志不止一个,就有可能是Delphi的Bug(看清楚,我说的是有可能)
HD_Copy咬牙切齿的说:“这更坚定了我转投VC++和C#的决心了!!!我现在最希望微软
早日收购Borland!!”

Btw:我用的是Delphi5+各种补丁,C++Builder+各种补丁,Win2000+sp2+IE6+各种安全补丁
 
也不至于如此偏激吧? 找到原因再说。
 
delphi 6加 win2k与你遇到的问题一样!
 
没问题的:
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items.Clear;
SearchFiles('C:/Winnt/system32/'); //我改成c:/windows/system32
end;
我只能在wind98下测试。

luck!
 
没想到HD_Copy大侠也要投奔VC++和C#了,
看来delphi是大势已去了啊,
我也赶紧撤!呵呵[:D]
 
我的也有问题,系统是win200p+sp2+delphi6
 
看来是有些问题,看看shellapi单元的源码,它调用了系统 shell32单元的几个函数:
{ Begin SHGetFileInfo }

(*
* The SHGetFileInfo API provides an easy way to get attributes
* for a file given a pathname.
*
* PARAMETERS
*
* pszPath file name to get info about
* dwFileAttributes file attribs, only used with SHGFI_USEFILEATTRIBUTES
* psfi place to return file info
* cbFileInfo size of structure
* uFlags flags
*
* RETURN
* TRUE if things worked
*)

type
PSHFileInfoA = ^TSHFileInfoA;
PSHFileInfoW = ^TSHFileInfoW;
PSHFileInfo = PSHFileInfoA;
{$EXTERNALSYM _SHFILEINFOA}
_SHFILEINFOA = record
hIcon: HICON; { out: icon }
iIcon: Integer; { out: icon index }
dwAttributes: DWORD; { out: SFGAO_ flags }
szDisplayName: array [0..MAX_PATH-1] of AnsiChar; { out: display name (or path) }
szTypeName: array [0..79] of AnsiChar; { out: type name }
end;
{$EXTERNALSYM _SHFILEINFOW}
_SHFILEINFOW = record
hIcon: HICON; { out: icon }
iIcon: Integer; { out: icon index }
dwAttributes: DWORD; { out: SFGAO_ flags }
szDisplayName: array [0..MAX_PATH-1] of WideChar; { out: display name (or path) }
szTypeName: array [0..79] of WideChar; { out: type name }
end;
{$EXTERNALSYM _SHFILEINFO}
_SHFILEINFO = _SHFILEINFOA;
TSHFileInfoA = _SHFILEINFOA;
TSHFileInfoW = _SHFILEINFOW;
TSHFileInfo = TSHFileInfoA;
{$EXTERNALSYM SHFILEINFOA}
SHFILEINFOA = _SHFILEINFOA;
{$EXTERNALSYM SHFILEINFOW}
SHFILEINFOW = _SHFILEINFOW;
{$EXTERNALSYM SHFILEINFO}
SHFILEINFO = SHFILEINFOA;

const
{$EXTERNALSYM SHGFI_ICON}
SHGFI_ICON = $000000100; { get icon }
{$EXTERNALSYM SHGFI_DISPLAYNAME}
SHGFI_DISPLAYNAME = $000000200; { get display name }
{$EXTERNALSYM SHGFI_TYPENAME}
SHGFI_TYPENAME = $000000400; { get type name }
{$EXTERNALSYM SHGFI_ATTRIBUTES}
SHGFI_ATTRIBUTES = $000000800; { get attributes }
{$EXTERNALSYM SHGFI_ICONLOCATION}
SHGFI_ICONLOCATION = $000001000; { get icon location }
{$EXTERNALSYM SHGFI_EXETYPE}
SHGFI_EXETYPE = $000002000; { return exe type }
{$EXTERNALSYM SHGFI_SYSICONINDEX}
SHGFI_SYSICONINDEX = $000004000; { get system icon index }
{$EXTERNALSYM SHGFI_LINKOVERLAY}
SHGFI_LINKOVERLAY = $000008000; { put a link overlay on icon }
{$EXTERNALSYM SHGFI_SELECTED}
SHGFI_SELECTED = $000010000; { show icon in selected state }
{$EXTERNALSYM SHGFI_LARGEICON}
SHGFI_LARGEICON = $000000000; { get large icon }
{$EXTERNALSYM SHGFI_SMALLICON}
SHGFI_SMALLICON = $000000001; { get small icon }
{$EXTERNALSYM SHGFI_OPENICON}
SHGFI_OPENICON = $000000002; { get open icon }
{$EXTERNALSYM SHGFI_SHELLICONSIZE}
SHGFI_SHELLICONSIZE = $000000004; { get shell size icon }
{$EXTERNALSYM SHGFI_PIDL}
SHGFI_PIDL = $000000008; { pszPath is a pidl }
{$EXTERNALSYM SHGFI_USEFILEATTRIBUTES}
SHGFI_USEFILEATTRIBUTES = $000000010; { use passed dwFileAttribute }

{$EXTERNALSYM SHGetFileInfo}
function SHGetFileInfo(pszPath: PAnsiChar; dwFileAttributes: DWORD;
var psfi: TSHFileInfo; cbFileInfo, uFlags: UINT): DWORD; stdcall;
{$EXTERNALSYM SHGetFileInfoA}
function SHGetFileInfoA(pszPath: PAnsiChar; dwFileAttributes: DWORD;
var psfi: TSHFileInfoA; cbFileInfo, uFlags: UINT): DWORD; stdcall;
{$EXTERNALSYM SHGetFileInfoW}
function SHGetFileInfoW(pszPath: PAnsiChar; dwFileAttributes: DWORD;
var psfi: TSHFileInfoW; cbFileInfo, uFlags: UINT): DWORD; stdcall;

const
{$EXTERNALSYM SHGNLI_PIDL}
SHGNLI_PIDL = $000000001; { pszLinkTo is a pidl }
{$EXTERNALSYM SHGNLI_PREFIXNAME}
SHGNLI_PREFIXNAME = $000000002; { Make name "Shortcut to xxx" }
{$EXTERNALSYM SHGNLI_NOUNIQUE}
SHGNLI_NOUNIQUE = $000000004; { don't do the unique name generation }

shell32 = 'shell32.dll';
implementation
......
function SHGetFileInfo; external shell32 name 'SHGetFileInfoA';
function SHGetFileInfoA; external shell32 name 'SHGetFileInfoA';
function SHGetFileInfoW; external shell32 name 'SHGetFileInfoW';
......
 
to All:
看来和我效果一样的同志越来越多了,大家都仔细分析一下原因吧,谢谢!
to 小人物:
你太过奖了!我算什么大侠,狗屁不是!!!!TMD,气死我了!!![:(!][:(!][:(!]
 
http://swchen.jhnet.com.cn/project1.exe
 
在Wind2000+D6.5下测试可以!
 
绝对没有什么问题,你要不重新装系统吧,delphi在我的机器上也是老是犯些莫名其妙的问题
 
如果仅仅是取出winnt/system32的文件类型,那么
SHGetFileInfo(PChar(CurrentPath+sr.Name), 0, FileInfo, SizeOf(FileInfo),SHGFI_TYPENAME or SHGFI_ATTRIBUTES )就可以了
另外searchFiles可以这样写,也不会出错。

iFound := FindFirst(CurrentPath + '*.*', faAnyFile, sr);
FillChar(FileInfo, SizeOf(FileInfo), #0);
while iFound=0 do
begin
// if (sr.Attr<>faDirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
if SHGetFileInfo(PChar(CurrentPath+sr.Name), 0, FileInfo, SizeOf(FileInfo),SHGFI_TYPENAME )<>0 then
if FileInfo.szTypeName<>'文件夹' then
ListBox1.Items.Add(FileInfo.szTypeName);
end;
iFound := FindNext(sr);
end;
FindClose(sr);

具体原因不明,一步一步地单步执行,发现在
ShGetFileInfo
处程序会自动分成两个线程同时运行。这说明ShGetFileInfo调用是一
个线程级的系统调用。Delphi有一套自己
的管理线程的机制,在多线程环境里,程序结束后,有的线程并没有结
束,如果立即再次运行,往往会造成系统崩溃.
而当你运行一下opendialog,也许就对某些系统变量有一个初始化,
你可以在原来的程序 SearchFiles('C:/winnt/system32/');
之前加上opendialog1.execute;就不会出错。
具体原因俺还是弄不清楚。
 
该说的大家都说了,
骗得money而已!
 
我觉得代码没什么问题,
 
我在c++b5里运行没问题
 
仔细试了一下,你的代码没问题,不论在win98下还是在win XP下。
估计你的操作系统有问题。
 
后退
顶部