1 /* $Id: desktop.c,v 1.1 2004/04/29 14:41:26 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/userenv/desktop.c
6 * PURPOSE: Desktop and start menu support functions.
7 * PROGRAMMER: Eric Kohl
19 /* FUNCTIONS ***************************************************************/
22 GetDesktopPath (BOOL bCommonPath
,
25 WCHAR szPath
[MAX_PATH
];
30 DPRINT ("GetDesktopPath() called\n");
32 if (RegOpenKeyExW (HKEY_CURRENT_USER
,
33 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
38 DPRINT1 ("RegOpenKeyExW() failed\n");
42 dwLength
= MAX_PATH
* sizeof(WCHAR
);
43 if (RegQueryValueExW (hKey
,
44 bCommonPath
? L
"Common Desktop" : L
"Desktop",
50 DPRINT1 ("RegQueryValueExW() failed\n");
57 if (dwType
== REG_EXPAND_SZ
)
59 ExpandEnvironmentStringsW (szPath
,
65 wcscpy (lpDesktopPath
, szPath
);
68 DPRINT ("GetDesktopPath() done\n");
75 AddDesktopItemA (BOOL bCommonItem
,
78 LPCSTR lpIconLocation
,
80 LPCSTR lpWorkingDirectory
,
84 DPRINT1 ("AddDesktopItemA() not implemented!\n");
90 AddDesktopItemW (BOOL bCommonItem
,
93 LPCWSTR lpIconLocation
,
95 LPCWSTR lpWorkingDirectory
,
99 WCHAR szLinkPath
[MAX_PATH
];
100 WCHAR szArguments
[MAX_PATH
];
101 WCHAR szCommand
[MAX_PATH
];
109 DPRINT ("AddDesktopItemW() called\n");
113 if (!GetDesktopPath (bCommonItem
, szLinkPath
))
115 DPRINT1 ("GetDesktopPath() failed\n");
119 DPRINT ("Desktop path: '%S'\n", szLinkPath
);
121 /* FIXME: Make sure the path exists */
123 wcscat (szLinkPath
, L
"\\");
124 wcscat (szLinkPath
, lpItemName
);
125 wcscat (szLinkPath
, L
".lnk");
126 DPRINT ("Link path: '%S'\n", szLinkPath
);
128 /* Split 'lpArguments' string into command and arguments */
129 Ptr
= wcschr (lpArguments
, L
' ');
130 DPRINT ("Ptr %p lpArguments %p\n", Ptr
, lpArguments
);
133 dwLength
= (DWORD
)(Ptr
- lpArguments
);
134 DPRINT ("dwLength %lu\n", dwLength
);
135 memcpy (szCommand
, lpArguments
, dwLength
* sizeof(WCHAR
));
136 szCommand
[dwLength
] = 0;
138 wcscpy (szArguments
, Ptr
);
142 wcscpy (szCommand
, lpArguments
);
145 DPRINT ("szCommand: '%S'\n", szCommand
);
146 DPRINT ("szArguments: '%S'\n", szArguments
);
150 hr
= CoCreateInstance(&CLSID_ShellLink
,
152 CLSCTX_INPROC_SERVER
,
161 hr
= psl
->lpVtbl
->QueryInterface(psl
,
166 psl
->lpVtbl
->SetDescription(psl
,
169 psl
->lpVtbl
->SetPath(psl
,
172 psl
->lpVtbl
->SetArguments(psl
,
175 psl
->lpVtbl
->SetIconLocation(psl
,
179 if (lpWorkingDirectory
!= NULL
)
181 psl
->lpVtbl
->SetWorkingDirectory(psl
,
186 psl
->lpVtbl
->SetWorkingDirectory(psl
,
187 L
"%HOMEDRIVE%%HOMEPATH%");
190 psl
->lpVtbl
->SetHotkey(psl
,
193 psl
->lpVtbl
->SetShowCmd(psl
,
196 hr
= ppf
->lpVtbl
->Save(ppf
,
202 ppf
->lpVtbl
->Release(ppf
);
205 psl
->lpVtbl
->Release(psl
);
209 DPRINT ("AddDesktopItemW() done\n");
216 DeleteDesktopItemA (BOOL bCommonItem
,
219 DPRINT1 ("DeleteDesktopItemA() not implemented!\n");
225 DeleteDesktopItemW (BOOL bCommonItem
,
228 WCHAR szLinkPath
[MAX_PATH
];
230 DPRINT ("DeleteDesktopItemW() called\n");
232 if (!GetDesktopPath (bCommonItem
, szLinkPath
))
234 DPRINT1 ("GetDesktopPath() failed\n");
238 wcscat (szLinkPath
, L
"\\");
239 wcscat (szLinkPath
, lpItemName
);
240 wcscat (szLinkPath
, L
".lnk");
241 DPRINT ("Link path: '%S'\n", szLinkPath
);
243 return DeleteFile (szLinkPath
);