471,337 Members | 1,102 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 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 1515
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Igor Fedorow | last post: by
13 posts views Thread by LRW | last post: by
8 posts views Thread by Jim Butler | last post: by
2 posts views Thread by Ryan | last post: by
5 posts views Thread by =?Utf-8?B?SmVzc2ljYQ==?= | last post: by
reply views Thread by rosydwin | last post: by

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.