Solved

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

Posted on 2007-11-30
6
940 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 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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 Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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