Click here to Skip to main content
15,916,838 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get Table Names while using ADO Pin
John M. Drescher27-Apr-04 16:36
John M. Drescher27-Apr-04 16:36 
GeneralAccessing public variables Pin
Krugger40427-Apr-04 10:25
Krugger40427-Apr-04 10:25 
GeneralRe: Accessing public variables Pin
Joaquín M López Muñoz27-Apr-04 10:46
Joaquín M López Muñoz27-Apr-04 10:46 
GeneralRe: Accessing public variables Pin
Ravi Bhavnani27-Apr-04 11:14
professionalRavi Bhavnani27-Apr-04 11:14 
GeneralWindows Style Pin
Anthony988727-Apr-04 8:30
Anthony988727-Apr-04 8:30 
GeneralRe: Windows Style Pin
David Crow27-Apr-04 8:55
David Crow27-Apr-04 8:55 
Generalchar* shows up as sbyte* Pin
schoolGirl27-Apr-04 8:27
schoolGirl27-Apr-04 8:27 
GeneralRe: char* shows up as sbyte* Pin
Antti Keskinen27-Apr-04 11:04
Antti Keskinen27-Apr-04 11:04 
This is a multifaceted problem. Firstly, what is happening is that when you load a C++ DLL into a C# project/environment (such as .Net), it will attempt to convert all existing datatypes inside the DLL into CLR-compliant (.Net Framework compliant) types. The SBYTE structure represents a non-CLR-compliant 8-bit signed integer.

The reason, most obviously, for this is that your C++ DLL is created as ANSI-compilant, in which a char represents a signed 8-bit integer. However, in the C# environment, a char stands for an Unicode character.

Now, the solving might be attempted through the importing settings of the IDE. There should be, somewhere, an option to specify how non-CLR types are imported. I have never done this myself, so I am uncertain of where the actual option might be. Naturally, if you could specify HOW you are actually using the DLL (Importing it through a directive, linking with it, or by some other means), it might provide helpful.

Additionally, as char* types represent strings, and the concept of strings is wrapped into the 'String' type in C#, a viable approach into this problem would be to create a cross-platform DLL.
Did you know that you can use the Managed Extensions of C++ to write C++ code that takes advantage of the .Net framework ? In this approach, you can specify all special types, such as 'String' types, into your code, and they should be correctly imported by the C# project. The most magnificient thing is that if you use MC++ (Managed Extensions for C++), you can write code that runs on both a CLR-system (OS with .Net support) or a non-CLR one (Windows 95/98/old NT's). Special care should be taken, however, when developing this type of a solution.

One alternative would be to write your DLL as Unicode-compilant, in which you'd be required to change all your char types to TCHAR constants, that are mapped by the compiler based on what character set you've selected (This option is found under Project Settings). Additionally, you'd need to use the wide versions of all character manipulation routines. Consult MSDN with the keyword 'TCHAR' for further information about character mappings.

Lastly, you could try a different approach altogether: create your own class that encapsulates a string. Then pass these classes around when you need string variables. This is like re-inventing the wheel, but at least you don't need to use the MC++, if you feel uncomfortable with it.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
QuestionCTabCtrl with CFormView? Pin
emanuelllle1227-Apr-04 7:21
emanuelllle1227-Apr-04 7:21 
AnswerRe: CTabCtrl with CFormView? Pin
toxcct27-Apr-04 8:45
toxcct27-Apr-04 8:45 
QuestionMenu with Icons? Pin
blue-marie27-Apr-04 7:03
blue-marie27-Apr-04 7:03 
AnswerRe: Menu with Icons? Pin
toxcct27-Apr-04 7:12
toxcct27-Apr-04 7:12 
GeneralRe: Menu with Icons? Pin
blue-marie27-Apr-04 7:33
blue-marie27-Apr-04 7:33 
GeneralRe: Menu with Icons? Pin
toxcct27-Apr-04 7:57
toxcct27-Apr-04 7:57 
AnswerRe: Menu with Icons? Pin
John R. Shaw27-Apr-04 7:35
John R. Shaw27-Apr-04 7:35 
GeneralDSN password and username Pin
skoizumi2911027-Apr-04 6:08
sussskoizumi2911027-Apr-04 6:08 
GeneralRe: DSN password and username Pin
Krugger40427-Apr-04 10:28
Krugger40427-Apr-04 10:28 
GeneralSetting up a timer Pin
Shay Harel27-Apr-04 6:08
Shay Harel27-Apr-04 6:08 
GeneralRe: Setting up a timer Pin
toxcct27-Apr-04 6:14
toxcct27-Apr-04 6:14 
GeneralRe: Setting up a timer Pin
David Crow27-Apr-04 6:42
David Crow27-Apr-04 6:42 
GeneralRe: Setting up a timer Pin
Paul Ranson27-Apr-04 7:56
Paul Ranson27-Apr-04 7:56 
GeneralRe: Setting up a timer Pin
Shay Harel28-Apr-04 3:59
Shay Harel28-Apr-04 3:59 
GeneralRe: Setting up a timer Pin
Paul Ranson28-Apr-04 23:00
Paul Ranson28-Apr-04 23:00 
GeneralPreprocessor Pin
Alexander M.,27-Apr-04 5:30
Alexander M.,27-Apr-04 5:30 
GeneralRe: Preprocessor Pin
toxcct27-Apr-04 5:55
toxcct27-Apr-04 5:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.