mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
Implement AddDesktopItem() and DeleteDesktopItem().
svn path=/trunk/; revision=9242
This commit is contained in:
parent
de1dd3b0d4
commit
4056581a21
6 changed files with 278 additions and 5 deletions
246
reactos/lib/userenv/desktop.c
Normal file
246
reactos/lib/userenv/desktop.c
Normal file
|
@ -0,0 +1,246 @@
|
|||
/* $Id: desktop.c,v 1.1 2004/04/29 14:41:26 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/userenv/desktop.c
|
||||
* PURPOSE: Desktop and start menu support functions.
|
||||
* PROGRAMMER: Eric Kohl
|
||||
*/
|
||||
|
||||
#include <ntos.h>
|
||||
#include <windows.h>
|
||||
#include <userenv.h>
|
||||
#include <tchar.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
static BOOL
|
||||
GetDesktopPath (BOOL bCommonPath,
|
||||
LPWSTR lpDesktopPath)
|
||||
{
|
||||
WCHAR szPath[MAX_PATH];
|
||||
DWORD dwLength;
|
||||
DWORD dwType;
|
||||
HKEY hKey;
|
||||
|
||||
DPRINT ("GetDesktopPath() called\n");
|
||||
|
||||
if (RegOpenKeyExW (HKEY_CURRENT_USER,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
{
|
||||
DPRINT1 ("RegOpenKeyExW() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dwLength = MAX_PATH * sizeof(WCHAR);
|
||||
if (RegQueryValueExW (hKey,
|
||||
bCommonPath ? L"Common Desktop" : L"Desktop",
|
||||
0,
|
||||
&dwType,
|
||||
(LPBYTE)szPath,
|
||||
&dwLength))
|
||||
{
|
||||
DPRINT1 ("RegQueryValueExW() failed\n");
|
||||
RegCloseKey (hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey (hKey);
|
||||
|
||||
if (dwType == REG_EXPAND_SZ)
|
||||
{
|
||||
ExpandEnvironmentStringsW (szPath,
|
||||
lpDesktopPath,
|
||||
MAX_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy (lpDesktopPath, szPath);
|
||||
}
|
||||
|
||||
DPRINT ("GetDesktopPath() done\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
AddDesktopItemA (BOOL bCommonItem,
|
||||
LPCSTR lpItemName,
|
||||
LPCSTR lpArguments,
|
||||
LPCSTR lpIconLocation,
|
||||
INT iIcon,
|
||||
LPCSTR lpWorkingDirectory,
|
||||
WORD wHotKey,
|
||||
INT iShowCmd)
|
||||
{
|
||||
DPRINT1 ("AddDesktopItemA() not implemented!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
AddDesktopItemW (BOOL bCommonItem,
|
||||
LPCWSTR lpItemName,
|
||||
LPCWSTR lpArguments,
|
||||
LPCWSTR lpIconLocation,
|
||||
INT iIcon,
|
||||
LPCWSTR lpWorkingDirectory,
|
||||
WORD wHotKey,
|
||||
INT iShowCmd)
|
||||
{
|
||||
WCHAR szLinkPath[MAX_PATH];
|
||||
WCHAR szArguments[MAX_PATH];
|
||||
WCHAR szCommand[MAX_PATH];
|
||||
LPWSTR Ptr;
|
||||
DWORD dwLength;
|
||||
IShellLinkW* psl;
|
||||
IPersistFile* ppf;
|
||||
HRESULT hr;
|
||||
BOOL bResult;
|
||||
|
||||
DPRINT ("AddDesktopItemW() called\n");
|
||||
|
||||
bResult = FALSE;
|
||||
|
||||
if (!GetDesktopPath (bCommonItem, szLinkPath))
|
||||
{
|
||||
DPRINT1 ("GetDesktopPath() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT ("Desktop path: '%S'\n", szLinkPath);
|
||||
|
||||
/* FIXME: Make sure the path exists */
|
||||
|
||||
wcscat (szLinkPath, L"\\");
|
||||
wcscat (szLinkPath, lpItemName);
|
||||
wcscat (szLinkPath, L".lnk");
|
||||
DPRINT ("Link path: '%S'\n", szLinkPath);
|
||||
|
||||
/* Split 'lpArguments' string into command and arguments */
|
||||
Ptr = wcschr (lpArguments, L' ');
|
||||
DPRINT ("Ptr %p lpArguments %p\n", Ptr, lpArguments);
|
||||
if (Ptr != NULL)
|
||||
{
|
||||
dwLength = (DWORD)(Ptr - lpArguments);
|
||||
DPRINT ("dwLength %lu\n", dwLength);
|
||||
memcpy (szCommand, lpArguments, dwLength * sizeof(WCHAR));
|
||||
szCommand[dwLength] = 0;
|
||||
Ptr++;
|
||||
wcscpy (szArguments, Ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy (szCommand, lpArguments);
|
||||
szArguments[0] = 0;
|
||||
}
|
||||
DPRINT ("szCommand: '%S'\n", szCommand);
|
||||
DPRINT ("szArguments: '%S'\n", szArguments);
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_ShellLink,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
&IID_IShellLinkW,
|
||||
(LPVOID*)&psl);
|
||||
if (!SUCCEEDED(hr))
|
||||
{
|
||||
CoUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hr = psl->lpVtbl->QueryInterface(psl,
|
||||
&IID_IPersistFile,
|
||||
(LPVOID*)&ppf);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
psl->lpVtbl->SetDescription(psl,
|
||||
lpItemName);
|
||||
|
||||
psl->lpVtbl->SetPath(psl,
|
||||
szCommand);
|
||||
|
||||
psl->lpVtbl->SetArguments(psl,
|
||||
szArguments);
|
||||
|
||||
psl->lpVtbl->SetIconLocation(psl,
|
||||
lpIconLocation,
|
||||
iIcon);
|
||||
|
||||
if (lpWorkingDirectory != NULL)
|
||||
{
|
||||
psl->lpVtbl->SetWorkingDirectory(psl,
|
||||
lpWorkingDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
psl->lpVtbl->SetWorkingDirectory(psl,
|
||||
L"%HOMEDRIVE%%HOMEPATH%");
|
||||
}
|
||||
|
||||
psl->lpVtbl->SetHotkey(psl,
|
||||
wHotKey);
|
||||
|
||||
psl->lpVtbl->SetShowCmd(psl,
|
||||
iShowCmd);
|
||||
|
||||
hr = ppf->lpVtbl->Save(ppf,
|
||||
szLinkPath,
|
||||
TRUE);
|
||||
if (SUCCEEDED(hr))
|
||||
bResult = TRUE;
|
||||
|
||||
ppf->lpVtbl->Release(ppf);
|
||||
}
|
||||
|
||||
psl->lpVtbl->Release(psl);
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
DPRINT ("AddDesktopItemW() done\n");
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
DeleteDesktopItemA (BOOL bCommonItem,
|
||||
LPCSTR lpItemName)
|
||||
{
|
||||
DPRINT1 ("DeleteDesktopItemA() not implemented!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
DeleteDesktopItemW (BOOL bCommonItem,
|
||||
LPCWSTR lpItemName)
|
||||
{
|
||||
WCHAR szLinkPath[MAX_PATH];
|
||||
|
||||
DPRINT ("DeleteDesktopItemW() called\n");
|
||||
|
||||
if (!GetDesktopPath (bCommonItem, szLinkPath))
|
||||
{
|
||||
DPRINT1 ("GetDesktopPath() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wcscat (szLinkPath, L"\\");
|
||||
wcscat (szLinkPath, lpItemName);
|
||||
wcscat (szLinkPath, L".lnk");
|
||||
DPRINT ("Link path: '%S'\n", szLinkPath);
|
||||
|
||||
return DeleteFile (szLinkPath);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -6,17 +6,17 @@ TARGET_NAME = userenv
|
|||
|
||||
TARGET_BASE = 0x74850000
|
||||
|
||||
TARGET_CFLAGS = -fno-builtin -D__USE_W32API
|
||||
TARGET_CFLAGS = -fno-builtin -D__USE_W32API -D_WIN32_IE=0x0400
|
||||
|
||||
# require os code to explicitly request A/W version of structs/functions
|
||||
TARGET_CFLAGS += -DUNICODE -D_UNICODE -Wall -Werror
|
||||
|
||||
TARGET_LFLAGS = -nostdlib -nostartfiles
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a ole32.a wine_uuid.a
|
||||
|
||||
TARGET_OBJECTS = directory.o environment.o profile.o misc.o registry.o \
|
||||
setup.o userenv.o
|
||||
TARGET_OBJECTS = desktop.o directory.o environment.o profile.o misc.o \
|
||||
registry.o setup.o userenv.o
|
||||
|
||||
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: profile.c,v 1.9 2004/04/19 10:51:17 ekohl Exp $
|
||||
/* $Id: profile.c,v 1.10 2004/04/29 14:41:26 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -646,6 +646,15 @@ CheckForLoadedProfile (HANDLE hToken)
|
|||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
LoadUserProfileA (HANDLE hToken,
|
||||
LPPROFILEINFOA lpProfileInfo)
|
||||
{
|
||||
DPRINT ("LoadUserProfileA() not implemented\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
LoadUserProfileW (HANDLE hToken,
|
||||
LPPROFILEINFOW lpProfileInfo)
|
||||
|
|
|
@ -3,12 +3,17 @@ EXPORTS
|
|||
InitializeProfiles@0 @100 NONAME
|
||||
CreateUserProfileA@8 @109 NONAME
|
||||
CreateUserProfileW@8 @110 NONAME
|
||||
AddDesktopItemA@32 @113 NONAME
|
||||
AddDesktopItemW@32 @114 NONAME
|
||||
DeleteDesktopItemA@8 @115 NONAME
|
||||
DeleteDesktopItemW@8 @116 NONAME
|
||||
CreateEnvironmentBlock@12
|
||||
DestroyEnvironmentBlock@4
|
||||
GetAllUsersProfileDirectoryW@8
|
||||
GetDefaultUserProfileDirectoryW@8
|
||||
GetProfilesDirectoryW@8
|
||||
GetUserProfileDirectoryW@12
|
||||
LoadUserProfileA@8
|
||||
LoadUserProfileW@8
|
||||
UnloadUserProfile@8
|
||||
;EOF
|
||||
|
|
|
@ -3,12 +3,17 @@ EXPORTS
|
|||
InitializeProfiles=InitializeProfiles@0 @100 NONAME
|
||||
CreateUserProfileA=CreateUserProfileA@8 @109 NONAME
|
||||
CreateUserProfileW=CreateUserProfileW@8 @110 NONAME
|
||||
AddDesktopItemA=AddDesktopItemA@32 @113 NONAME
|
||||
AddDesktopItemW=AddDesktopItemW@32 @114 NONAME
|
||||
DeleteDesktopItemA=DeleteDesktopItemA@8 @115 NONAME
|
||||
DeleteDesktopItemW=DeleteDesktopItemW@8 @116 NONAME
|
||||
CreateEnvironmentBlock=CreateEnvironmentBlock@12
|
||||
DestroyEnvironmentBlock=DestroyEnvironmentBlock@4
|
||||
GetAllUsersProfileDirectoryW=GetAllUsersProfileDirectoryW@8
|
||||
GetDefaultUserProfileDirectoryW=GetDefaultUserProfileDirectoryW@8
|
||||
GetProfilesDirectoryW=GetProfilesDirectoryW@8
|
||||
GetUserProfileDirectoryW=GetUserProfileDirectoryW@12
|
||||
LoadUserProfileA=LoadUserProfileA@8
|
||||
LoadUserProfileW=LoadUserProfileW@8
|
||||
UnloadUserProfile=UnloadUserProfile@8
|
||||
;EOF
|
||||
|
|
|
@ -40,6 +40,10 @@ typedef struct _PROFILEINFOW
|
|||
BOOL WINAPI InitializeProfiles (VOID);
|
||||
BOOL WINAPI CreateUserProfileA (PSID, LPCSTR);
|
||||
BOOL WINAPI CreateUserProfileW (PSID, LPCWSTR);
|
||||
BOOL WINAPI AddDesktopItemA (BOOL, LPCSTR, LPCSTR, LPCSTR, INT, LPCSTR, WORD, INT);
|
||||
BOOL WINAPI AddDesktopItemW (BOOL, LPCWSTR, LPCWSTR, LPCWSTR, INT, LPCWSTR, WORD, INT);
|
||||
BOOL WINAPI DeleteDesktopItemA (BOOL, LPCSTR);
|
||||
BOOL WINAPI DeleteDesktopItemW (BOOL, LPCWSTR);
|
||||
/* end private */
|
||||
BOOL WINAPI LoadUserProfileA (HANDLE, LPPROFILEINFOA);
|
||||
BOOL WINAPI LoadUserProfileW (HANDLE, LPPROFILEINFOW);
|
||||
|
@ -62,6 +66,8 @@ typedef PROFILEINFOW PROFILEINFO;
|
|||
typedef LPPROFILEINFOW LPPROFILEINFO;
|
||||
/* begin private */
|
||||
#define CreateUserProfile CreateUserProfileW
|
||||
#define AddDesktopItem AddDesktopItemW
|
||||
#define DeleteDesktopItem DeleteDesktopItemW
|
||||
/* end private */
|
||||
#define LoadUserProfile LoadUserProfileW
|
||||
#define GetAllUsersProfileDirectory GetAllUsersProfileDirectoryW
|
||||
|
@ -73,6 +79,8 @@ typedef PROFILEINFOA PROFILEINFO;
|
|||
typedef LPPROFILEINFOA LPPROFILEINFO;
|
||||
/* begin private */
|
||||
#define CreateUserProfile CreateUserProfileA
|
||||
#define AddDesktopItem AddDesktopItemA
|
||||
#define DeleteDesktopItem DeleteDesktopItemA
|
||||
/* end private */
|
||||
#define LoadUserProfile LoadUserProfileA
|
||||
#define GetAllUsersProfileDirectory GetAllUsersProfileDirectoryA
|
||||
|
|
Loading…
Reference in a new issue