Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlPanel.GetPath Exception #39

Closed
ervingegprifti opened this issue Feb 13, 2019 · 3 comments
Closed

ControlPanel.GetPath Exception #39

ervingegprifti opened this issue Feb 13, 2019 · 3 comments

Comments

@ervingegprifti
Copy link

I get an exception when trying to use ControlPanel.GetPath

Sample code:
ControlPanelItem cpi = ControlPanelItem.AutoPlay;
string path = ControlPanel.GetPath(cpi);

Exception:
Message: Error HRESULT E_FAIL has been returned from a call to a COM component.
Source: Vanara.PInvoke.Shell32
StackTrace: at Vanara.PInvoke.Shell32.IOpenControlPanel.GetPath(String pszName, StringBuilder pszPath, UInt32 cchPath) at Vanara.Windows.Shell.ControlPanel.GetPath(String item) at Vanara.Windows.Shell.ControlPanel.GetPath(ControlPanelItem item)

This is in a WPF project VS 2017 CE, Windows 10 64bit

@dahall
Copy link
Owner

dahall commented Feb 13, 2019

It appears others have had this exact problem when trying to use C# in the past to access this COM interface. However, I've tried this in C, and it works just fine. So, let me play with it for a few days and see if I can get it to work.

@dahall
Copy link
Owner

dahall commented Feb 15, 2019

I don't have a complete fix, but I do have at least a partial. I have gone through hours of iterations without any success other than this: Build your project with either "Any CPU" and not "Prefer 32-bit" OR "x64". These settings will cause the definition in the current library to pass the parameters properly.

@ervingegprifti
Copy link
Author

Hi David,
Yes if I uncheck "Prefer 32-bit" it is working correctly.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants