Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-30
6
Medium Priority
?
941 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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