From ff09513565aad66231bce53ef3aee0bec5edbd28 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 14 Mar 2015 12:10:33 +0000 Subject: [PATCH] [DESK] Implement and export InstallScreenSaver{A,W}. By Peter Hater. CORE-6812 svn path=/trunk/; revision=66688 --- reactos/dll/cpl/desk/desk.c | 77 ++++++++++++++++++++++++++++++++++ reactos/dll/cpl/desk/desk.spec | 4 +- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/reactos/dll/cpl/desk/desk.c b/reactos/dll/cpl/desk/desk.c index 0bbfa2556c8..9e5c39d1fe9 100644 --- a/reactos/dll/cpl/desk/desk.c +++ b/reactos/dll/cpl/desk/desk.c @@ -10,6 +10,7 @@ #include "desk.h" #include +#include #define NUM_APPLETS (1) @@ -209,6 +210,82 @@ CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2) return FALSE; } +void +WINAPI +InstallScreenSaverW( + IN HWND hWindow, + IN HANDLE hInstance, + IN LPCWSTR pszFile, + IN UINT nCmdShow) +{ + WCHAR pszSystemDir[MAX_PATH]; + WCHAR pszDrive[2]; + WCHAR pszPath[MAX_PATH]; + WCHAR pszFilename[MAX_PATH]; + WCHAR pszExt[MAX_PATH]; + LPWSTR pszOutName; + UINT uCompressionType=FILE_COMPRESSION_NONE; + DWORD dwSourceSize; + DWORD dwTargetSize; + DWORD rc; + + if (!pszFile) + { + DPRINT("InstallScreenSaver() null file\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return; + } + DPRINT("InstallScreenSaver() Installing screensaver %ls\n", pszFile); + + rc = SetupGetFileCompressionInfoW(pszFile, &pszOutName, &dwSourceSize, &dwTargetSize, &uCompressionType); + if (ERROR_SUCCESS != rc) + { + DPRINT("InstallScreenSaver() SetupGetFileCompressionInfo failed with error 0x%lx\n", rc); + SetLastError(rc); + return; + } + if (!GetSystemDirectoryW((LPWSTR)pszSystemDir, sizeof(pszSystemDir)/sizeof(WCHAR))) + { + MyFree(pszOutName); + DPRINT("InstallScreenSaver() GetSystemDirectory failed with error 0x%lx\n", GetLastError()); + return; + } + _wsplitpath(pszOutName, pszDrive, pszPath, pszFilename, pszExt); + MyFree(pszOutName); + StringCbCatW(pszSystemDir, sizeof(pszSystemDir), L"\\"); + StringCbCatW(pszSystemDir, sizeof(pszSystemDir), pszFilename); + StringCbCatW(pszSystemDir, sizeof(pszSystemDir), pszExt); + rc = SetupDecompressOrCopyFileW(pszFile, pszSystemDir, &uCompressionType); + DPRINT("InstallScreenSaver() Copying to %ls, compression type %d return 0x%lx\n", pszFile, uCompressionType, rc); +} + +void +WINAPI +InstallScreenSaverA( + IN HWND hWindow, + IN HANDLE hInstance, + IN LPCSTR pszFile, + IN UINT nCmdShow) +{ + LPWSTR lpwString; + + if (!pszFile) + { + DPRINT("InstallScreenSaver() null file\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return; + } + DPRINT("InstallScreenSaver() Install from file %s\n", pszFile); + lpwString = pSetupMultiByteToUnicode(pszFile, 0); + if (!lpwString) + { + DPRINT("InstallScreenSaver() not enough memory to convert string to unicode\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return; + } + InstallScreenSaverW(hWindow, hInstance, lpwString, nCmdShow); + MyFree(lpwString); +} BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpvReserved) diff --git a/reactos/dll/cpl/desk/desk.spec b/reactos/dll/cpl/desk/desk.spec index d870fd06d0e..05de0936888 100644 --- a/reactos/dll/cpl/desk/desk.spec +++ b/reactos/dll/cpl/desk/desk.spec @@ -1,3 +1,5 @@ @ stdcall CPlApplet(ptr long ptr ptr) @ stdcall DisplayClassInstaller(long ptr ptr) -@ stdcall DisplaySaveSettings(ptr ptr) \ No newline at end of file +@ stdcall DisplaySaveSettings(ptr ptr) +@ stdcall InstallScreenSaverW(long long ptr long) +@ stdcall InstallScreenSaverA(long long ptr long)