Use PathFileExists. it returns BOOL. you can check either file or path for existence.
How to check a shortcut exist or not in Windows?
-
14-06-2023 - |
문제
In my project, I need to create a shortcut for the special object. I use IPersistFile::Save to implement.
Now I have a new requirement that create multiple shortcut for the special object: "objectname-shortcut", "objectname-shortcut(2)", "objectname-shortcut(3)",...
If I call IPersistFile::Save directly, the new shortcut will overwrite the old one. So I need to check if there are some shortcuts exist already. If yes, I will pass a new name "objectname-shortcut(n)" to the IPersistFile::Save.
I know that the shortcut is a file essentially and I can use the API CreateFile to check it exist or not. But I want to know there is other method?
I have tried IPersistFile::Load, but it always return E_FAIL even the shortcut exist actually.
Thanks.
해결책