Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-30
6
Medium Priority
?
946 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

926 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