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

  • Thread starter Thread starter Mark Jerde
  • Start date Start date
M

Mark Jerde

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
 
Mark said:
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
 
Mark,
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
 
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.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

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