Solved

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

Posted on 2007-11-30
6
931 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Code works but I need to redo it and assign values to Model 7 33
Error in page 3 46
In WPF / C# binding a local database in code behind 1 24
Device Location 4 19
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

864 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

25 Experts available now in Live!

Get 1:1 Help Now