2013-02-25 2 views
2

내가 하나 또는 두 개의 마우스 클릭으로 바탕 화면 배경을 변경하는 작은 프로그램을 쓰고 있어요 등 8 세트 ..윈도우 바탕 화면 배경

나는 내가 바로 어떤 이미지 파일을 클릭하고 바탕 화면 배경으로 설정할 수 있다는 것을 알고.

정확하게 문제가있는 곳이 있습니다. 나는 엔트리가 데스크탑 배경으로 설정되거나 심지어 새로운 데스크탑 배경으로되는 모든 dll에서 적절한 엔트리를 찾을 수 없다.

나는 레지스트리에서 이들을 어떻게 만들 수 있는지 알고 있지만 레지스트리를 편집하고 싶지는 않지만 내 작은 프로그램에서 바로 설정하고 싶습니다. 두 번의 클릭으로 모든 이미지를 제어 할 수 있습니다. 파일을 바탕 화면 배경으로 표시 할 수 있습니다. 이 모든 폴더 또는 연결된 드라이브에서도 개인 설정 메뉴로 돌아 가지 않아도됩니다.

내가 위에서 언급 한 컨텍스트 메뉴 문자열의 항목을 어디에서 찾을 수 있는지 알고있는 사람이 있으면 매우 감사 할 것입니다.

이 단지 개인적인 사용을위한 것입니다 아니하며 판매하거나 버려야 ..

추신 : 크리스 감사 내 영어를 용서해주세요, 저는 영어가 아닌 유럽 국가 출신입니다. 당신은 예를 들어 보면

답변

0

, HKEY_CLASSES_ROOT \ SystemFileAssociations.jpg \ Shell은 \

명령

\ 당신은이 DelegateExecute 멤버 세트를 가지고 있음을 알 수 있습니다 setdesktopwallpaper. 즉, Windows는 지정된 DLL에서 IExecuteCommand 인터페이스를 사용하려고 시도합니다. MSDN에서하는 것을 읽고, 탐색기를 에뮬레이트하려고 시도하면서, 나는 이것을 생각해 냈다.

왜 슬립()이 필요한지 잘 모르겠지만 누군가가 그것에 대해 자세히 설명 할 수 있다면 좋겠다.

void SetWallpaper(LPCWSTR path) 
{ 
    const GUID CLSID_SetWallpaper = { 0xFF609CC7, 0xD34D, 0x4049, { 0xA1, 0xAA, 0x22, 0x93, 0x51, 0x7F, 0xFC, 0xC6 } }; 
    HRESULT hr; 
    IExecuteCommand *executeCommand = nullptr; 
    IObjectWithSelection *objectWithSelection = nullptr; 
    IShellItemArray *shellItemArray = nullptr; 
    IShellFolder *rootFolder = nullptr; 
    LPITEMIDLIST idlist = nullptr; 

    // Initalize COM, probably shouldn't be done in this function 
    hr = CoInitialize(nullptr); 
    if (SUCCEEDED(hr)) 
    { 
     // Get the IExecuteCommand interface of the DLL 
     hr = CoCreateInstance(CLSID_SetWallpaper, nullptr, CLSCTX_INPROC_SERVER, IID_IExecuteCommand, reinterpret_cast<LPVOID*>(&executeCommand)); 

     // Get the IObjectWithSelection interface 
     if (SUCCEEDED(hr)) 
     { 
      hr = executeCommand->QueryInterface(IID_IObjectWithSelection, reinterpret_cast<LPVOID*>(&objectWithSelection)); 
     } 

     // 
     if (SUCCEEDED(hr)) 
     { 
      hr = SHGetDesktopFolder(&rootFolder); 
     } 

     if (SUCCEEDED(hr)) 
     { 
      hr = rootFolder->ParseDisplayName(nullptr, nullptr, (LPWSTR)path, nullptr, &idlist, NULL); 
     } 

     if (SUCCEEDED(hr)) 
     { 
      hr = SHCreateShellItemArrayFromIDLists(1, (LPCITEMIDLIST*)&idlist, &shellItemArray); 
     } 

     if (SUCCEEDED(hr)) 
     { 
      hr = objectWithSelection->SetSelection(shellItemArray); 
     } 

     if (SUCCEEDED(hr)) 
     { 
      hr = executeCommand->Execute(); 
     } 

     // There is probably some event, or something to wait for here, but we 
     // need to wait and relinquish control of the CPU, or the wallpaper won't 
     // change. 
     Sleep(2000); 

     // Release interfaces and memory 
     if (idlist) 
     { 
      CoTaskMemFree(idlist); 
     } 
     if (executeCommand) 
     { 
      executeCommand->Release(); 
     } 
     if (objectWithSelection) 
     { 
      objectWithSelection->Release(); 
     } 
     if (shellItemArray) 
     { 
      shellItemArray->Release(); 
     } 
     if (rootFolder) 
     { 
      rootFolder->Release(); 
     } 

     CoUninitialize(); 
    } 
} 

편집 :이 몇 가지 더 많은 연구를 수행 한 후, 내 자신을 위해, 나는 그 stobject.dll 실제로 단지 IDesktopWallpaper 인터페이스를 사용 깨달았다; CLSID_DesktopWallpaper의 일부인

http://msdn.microsoft.com/en-us/library/windows/desktop/hh706946(v=vs.85).aspx

관련 문제