|
-
June 4th, 2010, 04:57 AM
#1
GUI creation - getting filenames into unmanaged code
Hi
I think I'm in a bit of a muddle.
I've successsfully created a programme in unmanaged c++ that can read in a file, do something with the data, and export a results file. However the filenames are hardcoded, so I was thinking it would be nice to wrap a GUI around the programme. I've been writing in Visual Express 2008, and so thought, 'this'll be easy, I just click create Windows forms project, dump my code into it and draw up a nice little form that pops up browse boxes and takes the filename to pass into my code'.
This was where I discovered such a thing as Managed C++ existed, and that it's really quite hard to make it work with an unmanaged programme given that the managed code likes to use String, and that my code would really like to take a string.
Anyway, to cut to the chase.
I can navigate my way through an openFileDialog to find the file path to find it as a String variable. I want to pass that String as a string to my original code. What is the best way to do it? Do I have to re-write my original code in managed C++?
I have looked through the FAQs but I've missed this question if it's there.
Hope you can help.
Thanks
Ed
-
June 4th, 2010, 08:20 AM
#2
Re: GUI creation - getting filenames into unmanaged code
For most managed-unmanaged interoperability problems, search appropriate functions in the Marshal class. For example, to convert managed string to unmanaged, use Marshal::StringToHGlobalAnsi or Marshal::StringToHGlobalUni.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|