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.

[479 byte] By [Saune] at [2008-2-2]
# 1
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 at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
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.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3

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

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

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 4
<a title="Aryavart Jewlery India" href=" http://www.aryavartjewelry.com">aryavart Jewelry India</a>.
nirmik at 2008-2-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 5
www.aryavartjewelry.com
Nirmik at 2008-2-3 > top of Msdn Tech,Visual Basic,Visual Basic Language...