Solved

Need help converting c++ CString.Format to C#

Posted on 2007-11-30
6
926 Views
Last Modified: 2013-12-16
Hello everyone,

I need help converting the following C++ code to C#:

CString csVer;

DWORD nVer=GetSdkVersion();

DWORD nVersion=nVer&0x0000ffff;

DWORD nBuild=(nVer>>16)&0x0000ffff;

csVer.Format("My.dll ver is %04x build is %04x",nVersion,nBuild);

Open in new window

0
Comment
Question by:VirtueTech
  • 3
  • 3
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20385824
string csVer;
UInt32 nVer = GetSdkVersion();
UInt32 nVersion = nnVer & 0x0000ffff;
UInt32 nBuild = (nVer>>16) & 0x0000ffff;
csVer = string.Format("My.dll ver is {0:X4} build is {1:X4}", nVersion, nBuild);

that is, asumming you have correctly marshalled the GetSdkVersion() function.
0
 

Author Comment

by:VirtueTech
ID: 20386106
That worked. Thanks.

The strange thing is this though. The DLL version in windows states 4.7.0.0, but the C++, and the C# code you just provided, both return this as my SDK version:  "My.dll ver is 0407 build is 0612"

Any insight as to why?  

The C++ code is from the DLL manufacturer so I'm pretty sure the code to get the version is correct. Plus the return is the same for the C++ code and the C# code, so I know I marshalled the GetSDKVersion() method correctly.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20386124
version and build are differente concepts
version is correct
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:VirtueTech
ID: 20386159
so should I display the 0407 as "SDK Version 4.7"  ?

Can I get the other 4.7.0.0 out of the string above so that I can display it as 4.7.0.0?

Cause some of the other DLL's are 4.6.0.1, and I'd love to show that.
0
 

Author Comment

by:VirtueTech
ID: 20386807
Jaime, Ccan you just take a look at my last comment. Thanks.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20386822
Really I don't know because version numbering style can vary depending on provider, and even on version.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now