Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

winapi - Did SHOpenWithDialog API change in Windows 10?

I have a function which allows the user to edit a file, either with their default program, or choose a program using SHOpenFileDialog().

I'm calling it by PInvoke in C# (https://www.pinvoke.net/default.aspx/shell32/SHOpenWithDialog.html):

[DllImport("shell32.dll", EntryPoint = "SHOpenWithDialog", CharSet = CharSet.Unicode)]
private static extern int SHOpenWithDialog(IntPtr hWndParent, ref tagOPENASINFO oOAI);

I call it with flags OAIF_HIDE_REGISTRATION | OAIF_EXEC.

Under Windows 7, it returns 1 on success. Under Windows 10, it returns 0 on success. The documentation claims it returns S_OK, which is 0, but that page was created on 2018/12/05, so I don't know what the previous documentation for it said.

What is the correct way to check the return code? Should I be checking for either 0 or 1 return value? Or should I be checking the Environment.OSVersion and checking for different return codes based on the OS version? Can it ever returns 1 under Windows 10 as an error condition?

question from:https://stackoverflow.com/questions/65602416/did-shopenwithdialog-api-change-in-windows-10

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...