[DESK] Implement and export InstallScreenSaver{A,W}. By Peter Hater. CORE-6812

svn path=/trunk/; revision=66688
This commit is contained in:
Amine Khaldi 2015-03-14 12:10:33 +00:00
parent 6b8bf7348d
commit ff09513565
2 changed files with 80 additions and 1 deletions

View file

@ -10,6 +10,7 @@
#include "desk.h"
#include <cplext.h>
#include <debug.h>
#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)

View file

@ -1,3 +1,5 @@
@ stdcall CPlApplet(ptr long ptr ptr)
@ stdcall DisplayClassInstaller(long ptr ptr)
@ stdcall DisplaySaveSettings(ptr ptr)
@ stdcall DisplaySaveSettings(ptr ptr)
@ stdcall InstallScreenSaverW(long long ptr long)
@ stdcall InstallScreenSaverA(long long ptr long)