SetFileAttributes(FileName,FILE_ATTRIBUTE_HIDDEN);

解决方案 »

  1.   

    我用的是将已存在的DWORD值“1”改为“0”;(在Windows me/XP中)
      

  2.   

    您是添加键还是写入键值,
    添加键用RegCreateKeyEx(HKEY hKey,LPCTSTR lpSubKey,DWORD dwReserved,LPTSTR lpClass,DWORD dwOptions,REGSAM samDesired,LPSEQURITY_ATTRIBUTE lpSecurityAttributes,PHKEY phkResult,LPDWORD lpdwPosition);写入键值;
    LONG RegSetValueEx(HKEY hKey,LPCTSTR lpszValueName,DWORD dwReserved,DWORD dwType,CONST BYTE* lpData,DWORD cbData)HKEY hNewKey  = NULL;
    DWORD dwPosition  =0;
    LONG lRet = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Smallfool",0,NULL,
    REG_OPTION_NON_VOLATIVE,KEY_ALL_ACCESS,NULL,&hNewKey,&dwPosition);
    // 错误处理,略CString strAutor=_T("Smallfool");
    lRet = ::RegSetValueEx(hNewKey, "Author", 0, REG_SZ,(BYTE*)(LPCTSTR)strAuthor,
           strAuthor.GetLength());
      

  3.   

    我这里有个函数,你看看吧:
    SetSzKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPCTSTR mset)
    {
        LONG ires;
        HKEY hMyKey;
        DWORD count=strlen(mset)+1;
        ires=RegOpenKeyEx(hKey,lpSubKey,0,KEY_WRITE,&hMyKey);
        if(ERROR_SUCCESS!=ires)
            MessageBox("注册表打开错误");    
        else
            ires=RegSetValueEx(hMyKey,lpValueName,0,REG_SZ,(CONST BYTE*)mset,count);
        ires=RegCloseKey(hMyKey);
    }使用:
    CString m_deleteDir=_T("c:\\temp");
    SetSzKey(HKEY_CURRENT_USER,"Control Panel\\International","CleanDir",(LPCTSTR)m_deleteDir);