hi

got a problem, hope you can help
how can i get the full path of an icon on the desktop that i've clicked on with the mouse


greets klasru

english is not my language :grin:
Posted on 2002-06-14 01:56:47 by klasru
What is a 'mouse'?
Posted on 2002-06-14 02:02:09 by bazik
:) <------ forgot this in the last post

Only way I know, because I read this way in another programming forum, is to go to http://www.wotsit.org, get the LNK file format and write your own parser. To get the Desktop directory, just use SHGetSpecialFolderLocation.


P.S.:
Here is the source I ment. Seems like some work for Ernie :)



#include <windows.h>
#include <windowsx.h>
#include <objbase.h>
#include <shlobj.h>
#include <stdio.h>
#include <initguid.h>
#include <string.h>

main(int ac, char *av[])
{
IShellLink *psl;
HRESULT hres;
WIN32_FIND_DATA wfd;
char szGotPath[MAX_PATH];
IPersistFile *ppf;

if (ac != 2)
{
printf("Syntax: ln <pathname>\n");
return 0;
}

hres = CoInitialize(NULL);
if (!SUCCEEDED(hres))
printf("Could not open the COM library\n");

hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
&IID_IShellLink, (LPVOID *)&psl);
if (SUCCEEDED(hres))
{
hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);

if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];

MultiByteToWideChar(CP_ACP, 0, av[1], -1, wsz, MAX_PATH);

hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
if (SUCCEEDED(hres))
{
hres = psl->lpVtbl->Resolve(psl, 0, SLR_ANY_MATCH);

if (SUCCEEDED(hres))
{
strcpy(szGotPath, av[1]);

hres = psl->lpVtbl->GetPath(psl, szGotPath, MAX_PATH,
(WIN32_FIND_DATA *)&wfd, SLGP_SHORTPATH );
if (!SUCCEEDED(hres))
printf("GetPath failed!\n");

printf("This points to %s\n", wfd.cFileName);
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
printf("This is a directory\n");
}
}
else
printf("IPersistFile Load Error\n");
ppf->lpVtbl->Release(ppf);
}
else
printf("QueryInterface Error\n");
psl->lpVtbl->Release(psl);
}
else
printf("CoCreateInstance Error - hres = %08x\n", hres);
return 0;
}
Posted on 2002-06-14 02:09:08 by bazik
:eek:

thx for your strive think i will use the dropped files..

greets klasru
Posted on 2002-06-14 03:34:43 by klasru