|
There is no registry on Mac OS.
The equivalent to the registry is the "plist" (http://en.wikipedia.org/wiki/Property_list[^]).
You could use a "dot file" file to store data; those files are usually text files, but this is not standard Mac OS behaviour.
Watched code never compiles.
|
|
|
|
|
Although i am using Delphi the question can
be applied to c++ too.
If i have a .lnk file
that point to a link of http://.... type
HOW do i get the string http://.....
using IShellLink
GetPath or GetDescription or any thing else
do not give me a solution.
the GetWorkingDirectory give me system32 as path
but i want the string http://.....
any help???
|
|
|
|
|
There is a difference in .lnk and .url file. If you have .lnk file than it is a shortcuts of any file like .gif file and .exe file etc. If you have a .url file than it is a shortcut of any url like http://www.codeproject.com.
If it is .lnk than you can get the path of file by using GetPath
->[^]
If it is .url than you can get the path of URL by using GetURL ->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
No try and you will see you are wrong
I get blank on getpath!!!!!
And on GetWorkingDirectory i get system32 as the path!!!
|
|
|
|
|
limelect wrote: No try and you will see you are wrong
I already tested it and than give you suggestion.
Okie right click the .lnk file and check its tab: Is it "General", "Shortcut", "Security"?? If so than check in "Shortcut" tab there is one value on "Target".
Is it the value what you want?? "http://...".
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
Yes the target
Ok but now what function read it?
I could not find any
Since in "normal situation" the getpath
give the info needed
But on this case i tried all known functions
could not find one!!! that is the problem
|
|
|
|
|
Please share your code.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
It is a Delphi code but the sintax is the same
I have 2 code
second one is from jvcl
There are so many codes around i checked many none work for .lnk
I tried c++ code too
There is NO!! mistake in the code only to get the right function
to do the job
And This one dose not do the job either
http://www.codeproject.com/KB/shell/create_shortcut.aspx
var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
p:PItemIDList;
TargetName : WideString;
LinkInfo: TShellLinkInfoStruct;
s: string;
AStr: array [0..MAX_PATH] of Char;
begin
TargetName:='C:\Documents and Settings\Administrator\Desktop\AVS Video Converter HD. Perfect for home video conversion. Convert video fast and easily!.lnk';
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
ISLink.SetPath(pChar(TargetName)) ;
{ Load file into IPersistFile object }
IPFile.Load(PWideChar(TargetName), STGM_READ);
{ Resolve the link by calling the Resolve interface function. }
ISLink.Resolve(0, SLR_UPDATE{ANY_MATCH} {or SLR_NO_UI});
{ Get all the info! }
ISLink.GetPath(AStr, MAX_PATH, LinkInfo.FindData, SLGP_RAWPATH);
ISLink.GetWorkingDirectory(AStr, MAX_PATH);
__________________________JVCL CODE __________________________________________
procedure GetShellLinkInfo(const LinkFile: WideString; var SLI: TShellLinkInfo);
{ Retrieves information on an existing shell link }
var
SL: IShellLink;
PF: IPersistFile;
FindData: TWin32FindData;
AStr: array [0..MAX_PATH] of Char;
begin
OleCheck(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER,
IShellLink, SL));
{ The IShellLink implementer must also support the IPersistFile }
{ interface. Get an interface pointer to it. }
PF := SL as IPersistFile;
{ Load file into IPersistFile object }
OleCheck(PF.Load(PWideChar(LinkFile), STGM_READ));
{ Resolve the link by calling the Resolve interface function. }
OleCheck(SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI));
{ Get all the info! }
with SLI do
begin
OleCheck(SL.GetPath(AStr, MAX_PATH, FindData, SLGP_SHORTPATH));
PathName := AStr;
OleCheck(SL.GetArguments(AStr, MAX_PATH));
Arguments := AStr;
OleCheck(SL.GetDescription(AStr, MAX_PATH));
Description := AStr;
OleCheck(SL.GetWorkingDirectory(AStr, MAX_PATH));
WorkingDirectory := AStr;
OleCheck(SL.GetIconLocation(AStr, MAX_PATH, IconIndex));
IconLocation := AStr;
OleCheck(SL.GetShowCmd(ShowCmd));
OleCheck(SL.GetHotKey(HotKey));
end;
end;
|
|
|
|
|
Is your Target name is the folder where your .lnk file is placed ??
It should be the full path of .lnk file
Example : "c:\\abc\\file.lnk".
The example given in this link is same that I will give you.
How to create and resolve a shortcut[^]
I had created a sample project and it is working fine:
HRESULT CMy1Dlg::ResolveIt(HWND hwnd, LPCSTR lpszLinkFile, LPWSTR lpszPath, int iPathBufferSize)
{
HRESULT hres;
IShellLink* psl;
WCHAR szGotPath[MAX_PATH];
WCHAR szDescription[MAX_PATH];
WIN32_FIND_DATA wfd;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres))
{
hres = psl->Resolve(hwnd, 0);
if (SUCCEEDED(hres))
{
hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH);
if (SUCCEEDED(hres))
{
hres = psl->GetDescription(szDescription, MAX_PATH);
if (SUCCEEDED(hres))
{
hres = StringCbCopy(lpszPath, iPathBufferSize, szGotPath);
if (SUCCEEDED(hres))
{
}
else
{
}
}
}
}
}
ppf->Release();
}
psl->Release();
}
return hres;
}
ResolveIt(this->m_hWnd,"d:\\Documents and Settings\\s.p\\Desktop\\2.lnk",_T("d:\\Documents and Settings\\s.p\\Desktop\\2.lnk"),1024);
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
See in my source it is full path
It is crazy in my Delphi application i Dose NOT work.
i have exactly what you guise have and it dose not work
ON GETPATH
can i get from you a full SMALL application source so
i will compile it here and see the difference!!
I am an expert with Delphi but not 100% c++
I do not understand if you get the string with
getpath why it dose not work on delphi
i have 2 links as you can see in the source one works
ok the other no
I wander if FindData: TWin32FindData; is my problem since
you have it to WIN32_FIND_DATA wfd;
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
p:PItemIDList;
TargetName : WideString;
FindData: TWin32FindData;
s: string;
AStr: array [0..MAX_PATH] of Char;
begin
TargetName:='C:\Documents and Settings\Administrator\Desktop\AVS Video Converter HD. Perfect for home video conversion. Convert video fast and easily!.lnk';<<<<<< this is not it gives system32 for path
// TargetName:='C:\Documents and Settings\Administrator\Desktop\123FreeSolitaire.lnk';<<<<< this is ok
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
ISLink.SetPath(pChar(TargetName)) ;
{ Load file into IPersistFile object }
IPFile.Load(PWideChar(TargetName), STGM_READ);
{ Resolve the link by calling the Resolve interface function. }
ISLink.Resolve(0, SLR_UPDATE{ANY_MATCH} {or SLR_NO_UI});
{ Get all the info! }
ISLink.GetPath(AStr, MAX_PATH, FindData, SLGP_SHORTPATH);<<<<<< the same as yours
ISLink.GetWorkingDirectory(AStr, MAX_PATH);
ISLink.GetDescription(AStr, MAX_PATH);
|
|
|
|
|
Okie give me youyr mail id. I will send you sample application. The sample application that I had created is in VS2005.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
limelect@gmail.com
could you plz include source so i will compile and see the diffrence
I have visual studio 9 and 10 the free ver
thanks
P.S mysite www.limelect.com
I also have Delphi xe which include c++ too
|
|
|
|
|
Okie, I send you my sample application. There is one function
void CMy1Dlg::OnBnClickedOk()
Change the path of .lnk file and rebuild the source and execute it.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
thanks i will take care of once i will get it
|
|
|
|
|
Did you get the .lnk file and sources?
thanks
|
|
|
|
|
Did you receive my source code ??
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
If you did not receive what i send you
download zip file at
http://forums.about.com/n/pfx/forum.aspx?msg=19194.8&nav=messages&webtag=ab-delphi
with the .lnk file inside
|
|
|
|
|
Good, Now I understand your problem.
As far as I know
1) You create this .lnk file problematically, Manually it is not possible.
2) If Internet explorer and Mozilla is not open than click this link it will not open.
I did the same mistake in one of my project that's why I know this issue.
If I am right than create shortcut using "IUniformResourceLocator". .url file is created and with the help of IUniformResourceLocator you can get the correct path.
I am also getting a null string in my project because it is not a correct .lnk file.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
But windows properties (right mouse click) shows it is a legal
.lnk file
so now can you post a few line of code to GET THE STRING FROM IT?
And i thought i am wrong and do not know
what i am doing.
P.S I did note create this link an installation program did
and it is a legal link file
|
|
|
|
|
limelect wrote: I did note create this link an installation program did
and it is a legal link file
That is what I want to say you that manually this .lnk is not created.
Okie first create a shortcut of any file in your program and than change the target manually to http://www.codeproject.com. It will not allow you.
limelect wrote: so now can you post a few line of code to GET THE STRING FROM IT?
Google IUniformResourceLocator (GetURL) and try to create one project and check if it is working. (I am not sure it is working but you can try it).
limelect wrote: And i thought i am wrong and do not know
what i am doing.
Are you telling me that I am wrong or you understand what I wanna say ??
My suggestion: try to create url shortcut programatically with IUniformResourceLocator not with the help of installer.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
well Ok by the time i got your message
i did some research and found even in my librery
GETurl and SETurl using
const
CLSID_InternetShortcut: TGUID = (
D1:$FBF23B40; D2:$E3F0; D3:$101B; D4 84,$88,$00,$AA,$00,$3E,$56,$F8));
IID_IUniformResourceLocatorA: TGUID = (
D1:$FBF23B80; D2:$E3F0; D3:$101B; D4 84,$88,$00,$AA,$00,$3E,$56,$F8));
SID_IUniformResourceLocatorA = '{FBF23B80-E3F0-101B-8488-00AA003E56F8}';
and so on but even that DOSE NOT work
I have so much source on the matter (using IUniformResourceLocator) i did not know.
But since this .lnk file become an obsession proffesionaly
i will have to look even closer on the matter.
As for you, you have done more then enough and i appreciate it
You are the only one given a serious response and i thank you.
I think i am on my own now since nothing worked on the above file
and i will see what to do
If i will have good news i will let you know
And thanks again
P.S if you will happen to make a test application for that specific file let me know
|
|
|
|
|
limelect wrote: As for you, you have done more then enough and i appreciate it
You are the only one given a serious response and i thank you.
I think i am on my own now since nothing worked on the above file
and i will see what to do
If i will have good news i will let you know
And thanks again
You are most welcome.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
The IShellLink specifically states that it cannot be used to create URL shortcuts. The Windows Scripting host is the vehicle for creating them, but I am not sure how to invoke WSH features from C++. However, if you open a URL link with Notepad (or your favourite editor) you will see that it is a simple text file, so you can get the information directly from reading it via any of the stream or file functions.
The best things in life are not things.
|
|
|
|
|
NO sir NO URL !!!!!! link
but .lnk link
In my search for an answer EVERYBODY
makes the same mistake
You are right .URL is text.
But i am talking about .LNK
I have such a file that with its properties
one can see the http://........ STRING
I wander if the community dose not know that?
It seem to me that no one have an answer
since i posted the problem on at list 4 forums
If you want i can send you the file to see.
|
|
|
|
|
OK, I have just created a shortcut with a URL as target (in Windows 7), and it is the same as I described above: a text file of the format:
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://support.dell.com/
IDList=
Try opening your file in Notepad to see what its contents look like.
The best things in life are not things.
|
|
|
|