mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 17:45:41 +00:00
Implement AddItemW().
svn path=/trunk/; revision=9310
This commit is contained in:
parent
34d4fe2efd
commit
233a41e696
4 changed files with 196 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: desktop.c,v 1.4 2004/05/04 13:11:22 ekohl Exp $
|
/* $Id: desktop.c,v 1.5 2004/05/05 15:29:15 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -153,6 +153,8 @@ AddDesktopItemW (BOOL bCommonDesktop,
|
||||||
WCHAR szLinkPath[MAX_PATH];
|
WCHAR szLinkPath[MAX_PATH];
|
||||||
WCHAR szArguments[MAX_PATH];
|
WCHAR szArguments[MAX_PATH];
|
||||||
WCHAR szCommand[MAX_PATH];
|
WCHAR szCommand[MAX_PATH];
|
||||||
|
WIN32_FIND_DATA FindData;
|
||||||
|
HANDLE hFind;
|
||||||
LPWSTR Ptr;
|
LPWSTR Ptr;
|
||||||
DWORD dwLength;
|
DWORD dwLength;
|
||||||
IShellLinkW* psl;
|
IShellLinkW* psl;
|
||||||
|
@ -169,11 +171,26 @@ AddDesktopItemW (BOOL bCommonDesktop,
|
||||||
DPRINT1 ("GetDesktopPath() failed\n");
|
DPRINT1 ("GetDesktopPath() failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT ("Desktop path: '%S'\n", szLinkPath);
|
DPRINT ("Desktop path: '%S'\n", szLinkPath);
|
||||||
|
|
||||||
/* FIXME: Make sure the path exists */
|
/* Make sure the path exists */
|
||||||
|
hFind = FindFirstFileW (szLinkPath,
|
||||||
|
&FindData);
|
||||||
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
DPRINT1 ("'%S' does not exist\n", szLinkPath);
|
||||||
|
|
||||||
|
/* FIXME: create directory path */
|
||||||
|
if (!CreateDirectoryW (szLinkPath, NULL))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1 ("'%S' exists\n", szLinkPath);
|
||||||
|
FindClose (hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append backslash, item name and ".lnk" extension */
|
||||||
wcscat (szLinkPath, L"\\");
|
wcscat (szLinkPath, L"\\");
|
||||||
wcscat (szLinkPath, lpItemName);
|
wcscat (szLinkPath, lpItemName);
|
||||||
wcscat (szLinkPath, L".lnk");
|
wcscat (szLinkPath, L".lnk");
|
||||||
|
@ -329,7 +346,7 @@ CreateGroupW (LPCWSTR lpGroupName,
|
||||||
wcscat (szGroupPath, lpGroupName);
|
wcscat (szGroupPath, lpGroupName);
|
||||||
DPRINT ("Group path: '%S'\n", szGroupPath);
|
DPRINT ("Group path: '%S'\n", szGroupPath);
|
||||||
|
|
||||||
/* FIXME: Create nested directories */
|
/* FIXME: Create directory path */
|
||||||
if (!CreateDirectoryW (szGroupPath, NULL))
|
if (!CreateDirectoryW (szGroupPath, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -372,7 +389,7 @@ DeleteGroupW (LPCWSTR lpGroupName,
|
||||||
wcscat (szGroupPath, lpGroupName);
|
wcscat (szGroupPath, lpGroupName);
|
||||||
DPRINT ("Group path: '%S'\n", szGroupPath);
|
DPRINT ("Group path: '%S'\n", szGroupPath);
|
||||||
|
|
||||||
/* FIXME: Remove nested directories */
|
/* FIXME: Remove directory path */
|
||||||
if (!RemoveDirectoryW (szGroupPath))
|
if (!RemoveDirectoryW (szGroupPath))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -384,6 +401,171 @@ DeleteGroupW (LPCWSTR lpGroupName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI
|
||||||
|
AddItemA (LPCSTR lpGroupName,
|
||||||
|
BOOL bCommonGroup,
|
||||||
|
LPCSTR lpItemName,
|
||||||
|
LPCSTR lpArguments,
|
||||||
|
LPCSTR lpIconLocation,
|
||||||
|
INT iIcon,
|
||||||
|
LPCSTR lpWorkingDirectory,
|
||||||
|
WORD wHotKey,
|
||||||
|
INT iShowCmd)
|
||||||
|
{
|
||||||
|
DPRINT1 ("AddItemA() not implemented!\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI
|
||||||
|
AddItemW (LPCWSTR lpGroupName,
|
||||||
|
BOOL bCommonGroup,
|
||||||
|
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];
|
||||||
|
WIN32_FIND_DATA FindData;
|
||||||
|
HANDLE hFind;
|
||||||
|
LPWSTR Ptr;
|
||||||
|
DWORD dwLength;
|
||||||
|
IShellLinkW* psl;
|
||||||
|
IPersistFile* ppf;
|
||||||
|
HRESULT hr;
|
||||||
|
BOOL bResult;
|
||||||
|
|
||||||
|
DPRINT ("AddDesktopItemW() called\n");
|
||||||
|
|
||||||
|
bResult = FALSE;
|
||||||
|
|
||||||
|
if (!GetProgramsPath (bCommonGroup, szLinkPath))
|
||||||
|
{
|
||||||
|
DPRINT1 ("GetProgramsPath() failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT ("Programs path: '%S'\n", szLinkPath);
|
||||||
|
|
||||||
|
if (lpGroupName != NULL && *lpGroupName != 0)
|
||||||
|
{
|
||||||
|
wcscat (szLinkPath, L"\\");
|
||||||
|
wcscat (szLinkPath, lpGroupName);
|
||||||
|
|
||||||
|
/* Make sure the path exists */
|
||||||
|
hFind = FindFirstFileW (szLinkPath,
|
||||||
|
&FindData);
|
||||||
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
DPRINT ("'%S' does not exist\n", szLinkPath);
|
||||||
|
if (!CreateGroupW (lpGroupName,
|
||||||
|
bCommonGroup))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT ("'%S' exists\n", szLinkPath);
|
||||||
|
FindClose (hFind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
BOOL WINAPI
|
||||||
DeleteItemA (LPCSTR lpGroupName,
|
DeleteItemA (LPCSTR lpGroupName,
|
||||||
BOOL bCommonGroup,
|
BOOL bCommonGroup,
|
||||||
|
@ -436,6 +618,7 @@ DeleteItemW (LPCWSTR lpGroupName,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
*Ptr = 0;
|
*Ptr = 0;
|
||||||
|
DPRINT ("Item path: '%S'\n", szItemPath);
|
||||||
if (RemoveDirectoryW (szItemPath))
|
if (RemoveDirectoryW (szItemPath))
|
||||||
{
|
{
|
||||||
/* FIXME: Notify the shell */
|
/* FIXME: Notify the shell */
|
||||||
|
|
|
@ -5,6 +5,8 @@ CreateGroupA@8 @101 NONAME
|
||||||
CreateGroupW@8 @102 NONAME
|
CreateGroupW@8 @102 NONAME
|
||||||
DeleteGroupA@8 @103 NONAME
|
DeleteGroupA@8 @103 NONAME
|
||||||
DeleteGroupW@8 @104 NONAME
|
DeleteGroupW@8 @104 NONAME
|
||||||
|
AddItemA@36 @105 NONAME
|
||||||
|
AddItemW@36 @106 NONAME
|
||||||
DeleteItemA@16 @107 NONAME
|
DeleteItemA@16 @107 NONAME
|
||||||
DeleteItemW@16 @108 NONAME
|
DeleteItemW@16 @108 NONAME
|
||||||
CreateUserProfileA@8 @109 NONAME
|
CreateUserProfileA@8 @109 NONAME
|
||||||
|
|
|
@ -5,6 +5,8 @@ CreateGroupA=CreateGroupA@8 @101 NONAME
|
||||||
CreateGroupW=CreateGroupW@8 @102 NONAME
|
CreateGroupW=CreateGroupW@8 @102 NONAME
|
||||||
DeleteGroupA=DeleteGroupA@8 @103 NONAME
|
DeleteGroupA=DeleteGroupA@8 @103 NONAME
|
||||||
DeleteGroupW=DeleteGroupW@8 @104 NONAME
|
DeleteGroupW=DeleteGroupW@8 @104 NONAME
|
||||||
|
AddItemA=AddItemA@36 @105 NONAME
|
||||||
|
AddItemW=AddItemW@36 @106 NONAME
|
||||||
DeleteItemA=DeleteItemA@16 @107 NONAME
|
DeleteItemA=DeleteItemA@16 @107 NONAME
|
||||||
DeleteItemW=DeleteItemW@16 @108 NONAME
|
DeleteItemW=DeleteItemW@16 @108 NONAME
|
||||||
CreateUserProfileA=CreateUserProfileA@8 @109 NONAME
|
CreateUserProfileA=CreateUserProfileA@8 @109 NONAME
|
||||||
|
|
|
@ -48,6 +48,8 @@ BOOL WINAPI CreateGroupA (LPCSTR, BOOL);
|
||||||
BOOL WINAPI CreateGroupW (LPCWSTR, BOOL);
|
BOOL WINAPI CreateGroupW (LPCWSTR, BOOL);
|
||||||
BOOL WINAPI DeleteGroupA (LPCSTR, BOOL);
|
BOOL WINAPI DeleteGroupA (LPCSTR, BOOL);
|
||||||
BOOL WINAPI DeleteGroupW (LPCWSTR, BOOL);
|
BOOL WINAPI DeleteGroupW (LPCWSTR, BOOL);
|
||||||
|
BOOL WINAPI AddItemA (LPCSTR, BOOL, LPCSTR, LPCSTR, LPCSTR, INT, LPCSTR, WORD, INT);
|
||||||
|
BOOL WINAPI AddItemW (LPCWSTR, BOOL, LPCWSTR, LPCWSTR, LPCWSTR, INT, LPCWSTR, WORD, INT);
|
||||||
BOOL WINAPI DeleteItemA (LPCSTR, BOOL, LPCSTR, BOOL);
|
BOOL WINAPI DeleteItemA (LPCSTR, BOOL, LPCSTR, BOOL);
|
||||||
BOOL WINAPI DeleteItemW (LPCWSTR, BOOL, LPCWSTR, BOOL);
|
BOOL WINAPI DeleteItemW (LPCWSTR, BOOL, LPCWSTR, BOOL);
|
||||||
/* end private */
|
/* end private */
|
||||||
|
@ -76,6 +78,7 @@ typedef LPPROFILEINFOW LPPROFILEINFO;
|
||||||
#define DeleteDesktopItem DeleteDesktopItemW
|
#define DeleteDesktopItem DeleteDesktopItemW
|
||||||
#define CreateGroup CreateGroupW
|
#define CreateGroup CreateGroupW
|
||||||
#define DeleteGroup DeleteGroupW
|
#define DeleteGroup DeleteGroupW
|
||||||
|
#define AddItem AddItemW
|
||||||
#define DeleteItem DeleteItemW
|
#define DeleteItem DeleteItemW
|
||||||
/* end private */
|
/* end private */
|
||||||
#define LoadUserProfile LoadUserProfileW
|
#define LoadUserProfile LoadUserProfileW
|
||||||
|
@ -92,6 +95,7 @@ typedef LPPROFILEINFOA LPPROFILEINFO;
|
||||||
#define DeleteDesktopItem DeleteDesktopItemA
|
#define DeleteDesktopItem DeleteDesktopItemA
|
||||||
#define CreateGroup CreateGroupA
|
#define CreateGroup CreateGroupA
|
||||||
#define DeleteGroup DeleteGroupA
|
#define DeleteGroup DeleteGroupA
|
||||||
|
#define AddItem AddItemA
|
||||||
#define DeleteItem DeleteItemA
|
#define DeleteItem DeleteItemA
|
||||||
/* end private */
|
/* end private */
|
||||||
#define LoadUserProfile LoadUserProfileA
|
#define LoadUserProfile LoadUserProfileA
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue