Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > SHAddToRecentDocs problem
 

SHAddToRecentDocs problem

I used
SHAddToRecentDocs(2, installpath & myfile) to add myfile to Recent documents.

Then I used the following loop to Wait for the SHAddToRecentDocs to add
shortcut
Do While Dir(RecentPath & myfile & ".lnk") = ""
Loop

The problem is that it never gets out of the loop.

Could anybody help me to point out why ?
I checked the Recent path to be correct and also checked that the 'myfile'
is in the Recent folder.

Saune  Friday, May 27, 2005 11:28 AM
Hi,

Are u making a Win32 API call using Visual Basic.NET?
If so, then you need to make sure you have declared it as a Sub.



Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As
Long, ByVal pv As String)

 


If you have declared it as a Function instead of a Sub then it wont work.
Also make sure the extension of the file you are trying to add as an entry
is registered on your system

Regards,
Vikram
Vikram  Thursday, June 02, 2005 11:35 AM
Is it shortcut to an Executable? Windows XP does not allow executables to be added to the Recent Documents.

Also you need to be careful, recent documents can be disabled via Group Policy, so in some situations (which you may be experiencing) your code won't work.
David M. Kean  Tuesday, June 07, 2005 11:42 AM

I also have written a class that wraps the SHAddToRecentDocs method here:

http://davidkean.net/archive/2004/10/03/177.aspx

David M. Kean  Tuesday, June 07, 2005 11:44 AM
Hi,

Are u making a Win32 API call using Visual Basic.NET?
If so, then you need to make sure you have declared it as a Sub.



Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As
Long, ByVal pv As String)

 


If you have declared it as a Function instead of a Sub then it wont work.
Also make sure the extension of the file you are trying to add as an entry
is registered on your system

Regards,
Vikram
Vikram  Thursday, June 02, 2005 11:35 AM
Is it shortcut to an Executable? Windows XP does not allow executables to be added to the Recent Documents.

Also you need to be careful, recent documents can be disabled via Group Policy, so in some situations (which you may be experiencing) your code won't work.
David M. Kean  Tuesday, June 07, 2005 11:42 AM

I also have written a class that wraps the SHAddToRecentDocs method here:

http://davidkean.net/archive/2004/10/03/177.aspx

David M. Kean  Tuesday, June 07, 2005 11:44 AM

You can use google to search for other answers

Custom Search

More Threads

• Game Launcher Updater
• How to use variable variable name?
• counting letter
• Redistribution of .OCX files
• Polymorphism Performance
• menustrip child item visibility
• WINDOWS DOES NOT RECOGNIZE . -
• Is it possible to run a method by giving a it's name in string not by a referene?
• deleting from database
• Good use of the system.codecom.compiler