我根据文件的后缀名,通过注册表获取与该类型文件关联的系统默认图标的路径,但是发现后缀为html、exe在注册表中的路径值为%1,请问谁知道这表示什么意思?

解决方案 »

  1.   

    %1 就是你双击打开文件时的文件绝对路径。比如:txtfile的打开程序是notepad.exe,
    在注册表里面找到:[HKEY_CLASSES_ROOT\txtfile\shell\open\command],默认值为:F:\Windows\notepad.exe %1当双击(或右键点击“打开”).txt文件时,shell会先根据后缀名.txt找到其默认值txtfile,然后再找到打开方式,[HKEY_CLASSES_ROOT\txtfile\shell\open\command],
    得到F:\Windows\notepad.exe %1,%1将会被解释成该文件的绝对路径。
    这样,notepad.exe就能将你的这个文件打开了,而不是去打开其它的.txt文件
      

  2.   

    非常感谢woyaowenzi ,我还想请问一下为什么默认图标的索引有的是正的有的是负的?
    %SystemRoot%\System32\shell32.dll,23
    C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\vcpackages\VCProject.dll,-9文件类型为html的默认图标索引为23,而类型为dsw的默认图标索引为-9,索引为负的我可以提取出默认图标保存为Icon文件,但是为正的还没摸到门道,还望不吝指教。
     
      

  3.   

    还有我要说明的是我是要根据文件的后缀名,通过注册表查询关联的系统默认图标的路径,然后要保存为Icon图标。
      

  4.   


    HINSTANCE  hLibrary; // Load the DLL/EXE - NOTE: must be a 32bit EXE/DLL for this to work
    if( (hLibrary = LoadLibraryEx( cModulePath, NULL, LOAD_LIBRARY_AS_DATAFILE ) ) == NULL )
    {
    // Failed to load - abort
    throw DWORD(-1);
    }
    // Store the info
    EDII.szFileName = cModulePath;
    EDII.hInstance = hLibrary; // Fill in the listbox with the icons available
    IsFirst = true;
    lpGrobalID = NULL;
    if( ! EnumResourceNames( EDII.hInstance, RT_GROUP_ICON, (ENUMRESNAMEPROC )MyEnumProcedure, (LPARAM)NULL ) )
    {
    throw DWORD(-1);
    } SaveIcon( cModulePath, lpSaveIcon );如果正的表示索引的话回调函数MyEnumProcedure的每次调用是否按照图标的索引顺序进行的?
      

  5.   


    有这么个函数:ExtractIconEx
    UINT ExtractIconEx(
        LPCTSTR lpszFile,
        int nIconIndex,
        HICON *phiconLarge,
        HICON *phiconSmall,
        UINT nIcons
    );请查看其注释,详见MSDN:
    nIconIndex:
    Windows 95/98/Me, Windows NT 4.0 and later: If this value is a negative number and either phiconLarge or phiconSmall is not NULL, the function begins by extracting the icon whose resource identifier is equal to the absolute value of nIconIndex. For example, use -3 to extract the icon whose resource identifier is 3.意思是说,不论图标索引号是正还是负,全按绝对值来算。不知道对不对。反正我用这个函数从dll中提取图标时全按绝对值来算的,没什么问题。