473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Simple Qs: PInvoke C++ DLL Name & Version Info to C# Application

Hello. I don't need full details, just a recommendation from experts.

I wrote a lot of Pre-ANSI K&R C programs but I'm not a C++ expert. The
volume of C++ info available is daunting... <g>

I am working on a project where a C# GUI program uses a number of non-.NET
C++ DLLs. PInvoke is working fine for two-way comm with the DLLs. Each DLL
exposes the same interface.

I would like to extend the interface to retrieve the name of the DLL and its
version, e.g. "MyCppDllOne" and "0.5.1" Questions:

1. Are Unicode strings appropriate?
2. What is the best way to build these strings in the C++ code?
3. Is there a better way, that is, a Best Practice I'm missing?

Thanks.

-- Mark
Dec 14 '05 #1
3 1576
Mark Jerde wrote:
3. Is there a better way, that is, a Best Practice I'm missing?


For example, can/should I get the DLL version info directly from the DLL?
I'm not a .NET framework expert yet either...

-- Mark
Dec 14 '05 #2
Mark,
3. Is there a better way, that is, a Best Practice I'm missing?


For example, can/should I get the DLL version info directly from the DLL?
I'm not a .NET framework expert yet either...


Yes, if it has a version resource you can use the FileVersionInfo
class.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 14 '05 #3
Hi Mark,
1. Are Unicode strings appropriate?
2. What is the best way to build these strings in the C++ code?


If you mean you just want to transfer a string(which represents the DLL's
name or its version number) via an exported function, there is no problem
to use the Unicode string if needed. The Equivalent C++ Type to the .NET
String type is std::wstring<>, but an array of wchar_t characters also
works.
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Igor Fedorow | last post by:
Hello all, I have an XML file with an internal DTD which looks roughly like this: <?xml version="1.0"?> <!DOCTYPE root > ]> <root> <node>
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
8
by: Jim Butler | last post by:
What are the drawbacks if any to this approach of not using the gac for shared components... basically having a central directory located outside of iis, that all web applications have a virtual...
2
by: Varsha | last post by:
Hi, a) I have a windows 2003 server on my machine with in built .NET Framework 1.1. b) I have also installed .NET Framework 1.0 on this machine. c) I have a web service, when i try to...
2
by: Ryan | last post by:
Hi all, I've been banging my head on this for two days so I'd appreciate any pointers from the knowledgable amongst you. I have a win app that recurses through a path looking for assemblies to...
1
by: KShapiro | last post by:
Hi All, I am trying to assist my wife, by making a simple menu system for the website. The web page is a .php4 file and does an include of the navigation file. Before it includes that file at...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
1
by: eastlands | last post by:
I need to use an unmanaged c++ dll which uses structs that contain callbacks and also functions. I have included the appropriate c++ definitials and my c# translations below. I first defined the...
5
by: =?Utf-8?B?SmVzc2ljYQ==?= | last post by:
Hello, I have a pInvoke question. This is the C function that is exported from one of the C dll, extern __declspec(dllexport) IM_RET_CODE ST_import (IM_MODE mode, char *filename,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.