|
-
Aug 31st, 2002, 02:59 PM
#1
Thread Starter
Frenzied Member
Internet Shortcuts
I am unfamiliar with using object interface suck as IUnkown and I want to write a small bit of code to retrive the url from a inet shortcut and ofcourse it is a shell link variation and you need to use the interfaces to get propertirs from it. can someone help me out..?
Magiaus
If I helped give me some points.
-
Sep 2nd, 2002, 06:06 AM
#2
Do you know the name of the interface you get for the inet shortcut?
BTW an inet shortcut is just a plain text file with the URL written in it:
[InternetShortcut]\nURL=(url)\n\nModified=(some_time_stamp)\n
The standard ending is .LNK
I'm not sure if those are really newlines, they could be any other character. (non-breaking space maybe?)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 2nd, 2002, 10:27 AM
#3
Thread Starter
Frenzied Member
from MSDN
MSDN Home > MSDN Library > User Interface Design and Development > Shell Programmer's Guide > Intermediate Shell Techniques > Intermediate Shell Techniques: Programming the Shell > Creating Shortcuts
Internet Shortcuts
--------------------------------------------------------------------------------
The Internet shortcut object is used to create desktop shortcuts to Internet sites. Like shortcuts to items in the file system, Internet shortcuts take the form of an icon on the desktop. When the user clicks the icon, the browser is launched and displays the site associated with the shortcut.
The following topics are discussed.
Creating Internet Shortcuts
Accessing Property Storage
Interfaces
Functions
Creating Internet Shortcuts
You can create an Internet shortcut by using a WebBrowser control or with the URL of the page.
Creating an Internet Shortcut from a WebBrowser Control
If your application hosts a WebBrowser control, you can use the Internet shortcut object to create shortcuts in the following way.
Create an instance of the Internet shortcut object with CoCreateInstance, using a class identifier (CLSID) of CLSID_InternetShortcut.
Pass the pointer to the WebBrowser's IUnknown interface to the Internet shortcut object with IObjectWithSite::SetSite.
Call the Internet shortcut object's IPersistFile::Save method when you want to create a shortcut to the page being viewed by the WebBrowser control.
A shortcut will be created in the location specified in IPersistFile::Save. This location enables the WebBrowser control to restore its state, which includes the task of loading of the correct documents into framesets.
Creating an Internet Shortcut from a URL
You can also create an Internet shortcut if you have the URL of the page to which you want to link.
Create an instance of the Internet shortcut object with CoCreateInstance, using a CLSID of CLSID_InternetShortcut.
Use the SetURL method to set the URL in the shortcut.
Use the IPersistFile::Save method to save the shortcut file to a desired location.
Accessing Property Storage
The Internet shortcut object contains several properties that you can access through the object's IPropertySetStorage interface with the following procedure.
Get the IPropertySetStorage interface by calling QueryInterface with IID_IPropertySetStorage.
Access the Internet shortcut property storage set by calling IPropertySetStorage::Open with FMTID_Intshcut or FMTID_InternetSite to obtain the IPropertyStorage interface.
Read the property storage information with IPropertyStorage::ReadMultiple by passing the appropriate property ID.
With version 4.70 or higher of Shell32.dll, you can also retrieve the IPropertySetStorage interface by calling BindToStorage with the pidl parameter set to the .URL file and the riid parameter set to IID_IPropertySetStorage.
The following property IDs can be requested for FMTID_Intshcut.
PROPID Variant Type Description
PID_IS_URL VT_LPWSTR URL to which the shortcut leads
PID_IS_NAME VT_LPWSTR Name of the Internet shortcut
PID_IS_WORKINGDIR VT_LPWSTR Working directory for the shortcut
PID_IS_HOTKEY VT_UI2 Hotkey for the shortcut
PID_IS_SHOWCMD VT_I4 Show command for shortcut
PID_IS_ICONINDEX VT_I4 Index of the icon
PID_IS_ICONFILE VT_LPWSTR File that contains the icon
PID_IS_WHATSNEW VT_LPWSTR What's New text
PID_IS_AUTHOR VT_LPWSTR Author
PID_IS_DESCRIPTION VT_LPWSTR Description text of site
PID_IS_COMMENT VT_LPWSTR User annotated comment
The following property IDs can be requested for FMTID_InternetSite.
PROPID Variant Type Description
PID_INTSITE_WHATSNEW VT_LPWSTR What's New text
PID_INTSITE_AUTHOR VT_LPWSTR Author
PID_INTSITE_LASTVISIT VT_FILETIME Time site was last visited
PID_INTSITE_LASTMOD VT_FILETIME Time site was last modified
PID_INTSITE_VISITCOUNT VT_UI4 Number of times user has visited
PID_INTSITE_DESCRIPTION VT_LPWSTR Description text of site
PID_INTSITE_COMMENT VT_LPWSTR User annotated comment
PID_INTSITE_FLAGS VT_UI4 Indicates use of PIDISF_ flags (see below)
PID_INTSITE_CONTENTLEN N/A Not currently supported
PID_INTSITE_CONTENTCODE N/A Not currently supported
PID_INTSITE_RECURSE N/A Not currently supported
PID_INTSITE_WATCH N/A Not currently supported
PID_INTSITE_SUBSCRIPTION VT_UI8 SUBSCRIPTIONCOOKIE value for subscription manager
PID_INTSITE_URL VT_LPWSTR URL to which the shortcut leads
PID_INTSITE_TITLE VT_LPWSTR Title
PID_INTSITE_CODEPAGE VT_UI4 Codepage of the document
PID_INTSITE_TRACKING N/A Not currently supported
PID_INTSITE_ICONINDEX VT_I4 Index of the icon
PID_INTSITE_ICONFILE VT_LPWSTR File that contains the icon
The following are the Internet site flags.
Flag Description
PIDISF_RECENTLYCHANGED Indicates that a site was recently changed
PIDISF_CACHEDSTICKY Not currently supported
PIDISF_CACHEIMAGES Not currently supported
PIDISF_FOLLOWALLLINKS Not currently supported
Interfaces
The Internet shortcut object exposes a number of interfaces.
OLE interfaces
IDataObject
IPersistFile
IPersistStream
IOleCommandTarget
IPropertySetStorage
IObjectWithSite
Shell interfaces
IContextMenu2
IExtractIcon
INewShortcutHook
IShellExtInit
IShellLink
IShellPropSheetExt
IQueryInfo
Internet shortcut interfaces
IUniformResourceLocator.
Functions
There are several utility functions that can be used with the Internet shortcut object.
Internet shortcut utility functions
InetIsOffline
MIMEAssociationDialog
TranslateURL
URLAssociationDialog
Contact Us | E-Mail this Page | MSDN Flash Newsletter
© 2002 Microsoft Corporation. All rights reserved. Terms of Use Privacy Statement Accessibility
Magiaus
If I helped give me some points.
-
Sep 2nd, 2002, 10:29 AM
#4
Thread Starter
Frenzied Member
http://msdn.microsoft.com/library/de..._shortcuts.asp
that is the link. i reall am not clear on it at all bee man. If i could open it with a filestream i would be pleased but the person who asked this originally tried that. And I have tried it with normal shortcuts before....
I can write the code but how do i add the interface to my project..?
Magiaus
If I helped give me some points.
-
Sep 2nd, 2002, 11:03 AM
#5
Code:
#include <windows.h>
#include <intshcut.h>
bool CreateShortcut(LPCSTR strURL, LPOLESTR pszFileName)
{
// Assumes that CoInitialize was called
IUniformResourceLocator *pURL = NULL;
if(FAILED(CoCreateInstance(CLSID_InternetShortcut, NULL,
CLSCTX_INPROC_SERVER, IID_IUniformResourceLocator, (void**)&pURL)))
{
return false;
}
if(FAILED(pURL->SetURL(strURL, IURL_SETURL_FL_USE_DEFAULT_PROTOCOL)))
{
pURL->Release();
return false;
}
IPersistFile *pPF = NULL;
if(FAILED(pURL->QueryInterface(IID_IPersistFile, (void**)&pPF)))
{
pURL->Release();
return false;
}
pURL->Release();
if(FAILED(pPF->Save(pszFileName, TRUE)))
{
pPF->Release();
return false;
}
// is now saved
pPF->Release();
return true;
}
The SetURL was a hyperlink which led me to IUniformResourceLocator
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 2nd, 2002, 11:05 AM
#6
Thread Starter
Frenzied Member
cool. did you know about that header file or was it in the documentation because I didn't see it.
Thanks CornedBee.
Magiaus
If I helped give me some points.
-
Sep 2nd, 2002, 11:09 AM
#7
Was in the docs, at the bottom of the IUniformResourceLocator page.
Interface Information
Inherits from IUnknown
Header intshcut.h
Minimum availability Internet Explorer 4.0
Minimum operating systems Windows 95, Windows NT 4.0
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 2nd, 2002, 12:24 PM
#8
Thread Starter
Frenzied Member
ok
I can't seem to find any information on how to open an existing .url file and reading it properties. I assume I must somehow create an interface instance and bind it to the shortcut file i want but i am not seeing how to do it.
wait i see. IPersistFile::Load
Magiaus
If I helped give me some points.
-
Sep 2nd, 2002, 01:11 PM
#9
Thread Starter
Frenzied Member
I still need help. I want to make a class to exposes the IURL interface but I am still very unclear on instancing it and then using it.
I see where you create an instance in your CreateShortcut method CornedBee and I see how your checking to see if it FAILED and then using CoCreateInstance to create an instance and refreance it via pURL. At least I think thats what is going on. I have never heard of CoInitialize before or CoCreateInstance for that matter. I am thinking this could be very cool to learn. Right now I am about to look for Interfaces on msdn and how to implament them.
Thanks
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 03:41 AM
#10
Before you learn how to implement interfaces, you should learn more about how to use them. CoCreateInstance and CoInitialize are two of the most basic COM API functions.
CoInitialize must be called once by each rpocess that uses COM to initialize the COM library. When the process ends it must call CoUninitialize to shut COM down.
CoCreateInstance creates a COM object of the type referenced by the CLASS GUID (CLSID) and returns a pointer to it of the interface type referenced in the INTERFACE GUID (IID).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|