Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

binary file/o in managed c++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
The unProfessional - 04 Oct 2004 22:24 GMT
I'm having difficulty figuring out a simple way to dump unmanaged structure
and/or class data to binary files.

In standard C++:
--------------------------
typedef struct tagS1
{
    DWORD dwBlah;
    CHAR     szBlah[64];
} S1;

...

S1 s1;

FILE *fd = fopen ("c:\....", "wb");

fwrite (&s1, sizeof(s1), 1, fd);

fclose (fd);
--------------------------

I really don't want to have to move a ton of pre-defined structures to
managed code and use BinaryFormatters, pad my strings, etc.

I attempted to use fwrite in managed c++, but it appears to cause an error
in the internal file-locking mechanism.

Ultimately, I'm hoping to take advantage of some of the managed set,
especially easy GUI creation, but I need some pure-C++ functionality (such
as what's described above).  Doesn't managed C++ support the standard C++
libraries?  If not, isn't that contrary to it's purpose?

Any info or advice would be GREATLY appreciated :)

I'd like to harness some of the ease of the .net framework (better than
MFC), but without losing the ability to write regular old C++.  Is it even
possible?

Signature

Bill Merrill
Lead Developer
Merchant Companion

Ronald Laeremans [MSFT] - 07 Oct 2004 09:59 GMT
There is no reason that I know off that fwrite should not work identically.
Do you have a small repro case you could share?

Ronald Laeremans
Visual C++ team

> I'm having difficulty figuring out a simple way to dump unmanaged
> structure
[quoted text clipped - 35 lines]
> MFC), but without losing the ability to write regular old C++.  Is it even
> possible?
The unProfessional - 08 Oct 2004 20:35 GMT
Hi Ronald,

Thanks alot for your time.

I'll put together a quick example and send it on over... Should I email you
directly?

Sincerely,
Bill

> There is no reason that I know off that fwrite should not work identically.
> Do you have a small repro case you could share?
[quoted text clipped - 41 lines]
> > MFC), but without losing the ability to write regular old C++.  Is it even
> > possible?
Ronald Laeremans [MSFT] - 09 Oct 2004 01:12 GMT
Yes, you can mail me. The obvious transformation of my posting alias is my
real MS email address.

Ronald

> Hi Ronald,
>
[quoted text clipped - 57 lines]
> even
>> > possible?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.