473,561 Members | 3,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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. "MyCppDllOn e" 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 1595
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
1859
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
2339
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 (document.getElementById"].value=='1') { confirm('Are you sure you want to delete this file?'); } } ......
8
1358
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 dir named bin pointing to this dir. like below setup, all on each server in a farm web site root one vdir bin points to drive\sharedbin web...
2
3981
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 invoke the methods of it, it returns "404 not found error".
2
3802
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 load, it then attempts to load each file in turn and examine its properties for a 'marker' property that defines it as a licencable class. The...
1
1432
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 the top I have the following line of code to include my .js file. <script src="scripts/SideNav.js" language="JavaScript"...
5
2289
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 email. however all the information is missing form the email I only get the first form text field?? #!/bin/perl #...
1
6628
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 parameters as c# structs, but when I tried the call (to RtcInitialize) I got the following error: MarshalDirectiveException Method's type...
5
1776
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, ST_TYPES **st_type, ST_ERROR **st_error);
0
7558
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8072
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7924
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3591
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1171
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
884
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.