6 个解决方案
#1
不会,顶
#2
ftp服务器里面无论多少文件,他的图标都是由浏览的客户端来决定的。得到了每个文件的扩展名,也就可以知道其图标。
本地文件的图标获取方式你知道吧?
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
本地文件的图标获取方式你知道吧?
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
#3
上面的方法你需要创建一个临时文件,你也可以通过读取注册表方式来获取
TRegistry * reg = new TRegistry();
reg->RootKey = HKEY_CLASSES_ROOT;
AnsiString assoicate,exename ;
if(reg->OpenKey(".doc",false)){
assoicate = reg->ReadString("");
reg->CloseKey();
assoicate += "\\DefaultIcon";
if(reg->OpenKey(assoicate,false)){
exename = reg->ReadString("");
unsigned short Index = exename.SubString(exename.Length(),1).ToIntDef(1);
exename = exename.SubString(1,exename.Length()-2);
HICON icon = icon = ExtractAssociatedIcon(HInstance,exename.c_str(),&Index);
TIcon * nicon = new TIcon;
nicon->Handle = icon;
nicon->SaveToFile("c:\\a.ico");
delete nicon;
reg->CloseKey();
}
}
delete reg;
TRegistry * reg = new TRegistry();
reg->RootKey = HKEY_CLASSES_ROOT;
AnsiString assoicate,exename ;
if(reg->OpenKey(".doc",false)){
assoicate = reg->ReadString("");
reg->CloseKey();
assoicate += "\\DefaultIcon";
if(reg->OpenKey(assoicate,false)){
exename = reg->ReadString("");
unsigned short Index = exename.SubString(exename.Length(),1).ToIntDef(1);
exename = exename.SubString(1,exename.Length()-2);
HICON icon = icon = ExtractAssociatedIcon(HInstance,exename.c_str(),&Index);
TIcon * nicon = new TIcon;
nicon->Handle = icon;
nicon->SaveToFile("c:\\a.ico");
delete nicon;
reg->CloseKey();
}
}
delete reg;
#4
上面的说的很清楚!
#5
补充一下,你可将FTP目录中的文件名,全部保存在TStringList结构中,然后遍历StringList
TStringList *FileName = new TStringList();
for( int i=0; i<FileName->Count; i++ )
{
TStringList *templist = new TStringList();
tmpList->SaveToFile( FileName->Strings[i] ); //保存一个空的文件
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName->Strings[i]), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
//删除那个空的文件
DeleteFile( FileName->Strings[i]);
}
这样,FileImageList中就存放了你要的文件图标了!
TStringList *FileName = new TStringList();
for( int i=0; i<FileName->Count; i++ )
{
TStringList *templist = new TStringList();
tmpList->SaveToFile( FileName->Strings[i] ); //保存一个空的文件
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName->Strings[i]), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
//删除那个空的文件
DeleteFile( FileName->Strings[i]);
}
这样,FileImageList中就存放了你要的文件图标了!
#6
ok,谢啦
#1
不会,顶
#2
ftp服务器里面无论多少文件,他的图标都是由浏览的客户端来决定的。得到了每个文件的扩展名,也就可以知道其图标。
本地文件的图标获取方式你知道吧?
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
本地文件的图标获取方式你知道吧?
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
#3
上面的方法你需要创建一个临时文件,你也可以通过读取注册表方式来获取
TRegistry * reg = new TRegistry();
reg->RootKey = HKEY_CLASSES_ROOT;
AnsiString assoicate,exename ;
if(reg->OpenKey(".doc",false)){
assoicate = reg->ReadString("");
reg->CloseKey();
assoicate += "\\DefaultIcon";
if(reg->OpenKey(assoicate,false)){
exename = reg->ReadString("");
unsigned short Index = exename.SubString(exename.Length(),1).ToIntDef(1);
exename = exename.SubString(1,exename.Length()-2);
HICON icon = icon = ExtractAssociatedIcon(HInstance,exename.c_str(),&Index);
TIcon * nicon = new TIcon;
nicon->Handle = icon;
nicon->SaveToFile("c:\\a.ico");
delete nicon;
reg->CloseKey();
}
}
delete reg;
TRegistry * reg = new TRegistry();
reg->RootKey = HKEY_CLASSES_ROOT;
AnsiString assoicate,exename ;
if(reg->OpenKey(".doc",false)){
assoicate = reg->ReadString("");
reg->CloseKey();
assoicate += "\\DefaultIcon";
if(reg->OpenKey(assoicate,false)){
exename = reg->ReadString("");
unsigned short Index = exename.SubString(exename.Length(),1).ToIntDef(1);
exename = exename.SubString(1,exename.Length()-2);
HICON icon = icon = ExtractAssociatedIcon(HInstance,exename.c_str(),&Index);
TIcon * nicon = new TIcon;
nicon->Handle = icon;
nicon->SaveToFile("c:\\a.ico");
delete nicon;
reg->CloseKey();
}
}
delete reg;
#4
上面的说的很清楚!
#5
补充一下,你可将FTP目录中的文件名,全部保存在TStringList结构中,然后遍历StringList
TStringList *FileName = new TStringList();
for( int i=0; i<FileName->Count; i++ )
{
TStringList *templist = new TStringList();
tmpList->SaveToFile( FileName->Strings[i] ); //保存一个空的文件
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName->Strings[i]), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
//删除那个空的文件
DeleteFile( FileName->Strings[i]);
}
这样,FileImageList中就存放了你要的文件图标了!
TStringList *FileName = new TStringList();
for( int i=0; i<FileName->Count; i++ )
{
TStringList *templist = new TStringList();
tmpList->SaveToFile( FileName->Strings[i] ); //保存一个空的文件
TIcon *TheIcon = new TIcon();
TImageList *FileImageList = new TImageList();
TSHFileInof FileInfo;
SHGetFileInfo(PChar(FileName->Strings[i]), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
TheIcon->Handle = FileInfo.hIcon;
FileImageList->AddIcon(TheIcon);
//删除那个空的文件
DeleteFile( FileName->Strings[i]);
}
这样,FileImageList中就存放了你要的文件图标了!
#6
ok,谢啦