سؤال

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.

هل كانت مفيدة؟

المحلول

Use PathFileExists. it returns BOOL. you can check either file or path for existence.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top