开发者

Accessing C# user settings from a C++ Application

I am writing a C# program in Microsoft Visual Studio 2010 that stores some information inside of the local user settings like so:

Properties.Settings.Default.userActive.Add(connection.Active);  
Properties.Settings.Default.Save();

I also have a Visual C++ application that would like to read these stored user settings. Is it possible for my Visual C++ application to read the C# application's user settings?

Similarly, how 开发者_高级运维would I go about accessing the local user settings directory in C++?


It seems like there is no Microsoft sanctioned way to do what I am attempting to do. In case anyone else comes across this I will briefly explain what I've decided to do. Here was a helpful guide. I am ultimately just populating an xml file from the C# and placing it within the users AppData folder located at:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

I am then using my C++ to locate it using:

TCHAR myCharArray[MAX_PATH];
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA,(HANDLE)-1,SHGFP_TYPE_DEFAULT, myCharArray);

I then parse the XML file using C++ and read in the settings. This was a much more manual process than I would have liked, and leaves room for a lot of error unfortunately. Anyways, thanks everyone and good luck!


You can make the c# class COM callable through .NET COM Interoperability and COM callable wrappers.

Check out http://blogs.msdn.com/b/deeptanshuv/archive/2005/06/26/432870.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜