Click here to Skip to main content
15,913,186 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Font color in Dialogs Pin
Roger Allen14-May-04 6:05
Roger Allen14-May-04 6:05 
GeneralRe: Font color in Dialogs Pin
RChin14-May-04 4:55
RChin14-May-04 4:55 
GeneralHelp? C++ Macros in EXCEL Pin
culz14-May-04 3:18
culz14-May-04 3:18 
GeneralRe: Help? C++ Macros in EXCEL Pin
David Crow14-May-04 4:23
David Crow14-May-04 4:23 
GeneralRe: Help? C++ Macros in EXCEL Pin
f6414-May-04 7:38
f6414-May-04 7:38 
GeneralRe: Help? C++ Macros in EXCEL Pin
culz15-May-04 4:54
culz15-May-04 4:54 
QuestionHow to pass a string from c++ to c# Pin
peraonline14-May-04 2:50
peraonline14-May-04 2:50 
AnswerRe: How to pass a string from c++ to c# Pin
Mike Dimmick14-May-04 5:20
Mike Dimmick14-May-04 5:20 
You can try
[return: MarshalAs(UnmanagedType.LPStr)]
However, that's going to be tricky: what frees the string?

If you control both the C# code and the DLL, I'd change your API so it takes a string pointer and a size:
BOOL GetDescr( int id, char* pBuffer, int bufLen )
{
   if ( bufLen < LUNGHEZZA_STRINGA_MEM )
   {
      return FALSE;
   }
   else
   {
      strcpy( pBuffer, oggetto[id].descr );
      return TRUE;
   }
}
then call from C# like so:
[DllImport( "WebUtility.dll", EntryPoint=GetDescr )]
public static extern bool UnsafeGetDescr( int id, StringBuilder buffer, int bufLen );
 
public static extern string GetDescr( int id )
{
  StringBuilder sb = new StringBuilder( LUNGHEZZA_STRINGA_MEM );
  if ( !UnsafeGetDescr( id, sb, sb.Capacity ) )
  {
     return null;
  }
  else
  {
     return sb.ToString();
  }
}


Stability. What an interesting concept. -- Chris Maunder
GeneralRe: How to pass a string from c++ to c# Pin
peraonline17-May-04 22:41
peraonline17-May-04 22:41 
GeneralProcess monitor.... Pin
jothi14-May-04 1:28
jothi14-May-04 1:28 
GeneralRe: Process monitor.... Pin
Anthony_Yio14-May-04 1:34
Anthony_Yio14-May-04 1:34 
GeneralRe: Process monitor.... Pin
jothi18-May-04 20:31
jothi18-May-04 20:31 
GeneralRe: Process monitor.... Pin
Anthony_Yio18-May-04 21:54
Anthony_Yio18-May-04 21:54 
GeneralCListBox scroll bar not getting enabled Pin
FASTian14-May-04 1:25
FASTian14-May-04 1:25 
GeneralRe: CListBox scroll bar not getting enabled Pin
RChin14-May-04 1:51
RChin14-May-04 1:51 
GeneralRe: CListBox scroll bar not getting enabled Pin
FASTian14-May-04 2:19
FASTian14-May-04 2:19 
GeneralRe: CListBox scroll bar not getting enabled Pin
David Crow14-May-04 2:31
David Crow14-May-04 2:31 
GeneralRe: CListBox scroll bar not getting enabled Pin
FASTian14-May-04 3:54
FASTian14-May-04 3:54 
GeneralRe: CListBox scroll bar not getting enabled Pin
David Crow14-May-04 4:22
David Crow14-May-04 4:22 
GeneralRe: CListBox scroll bar not getting enabled Pin
FASTian16-May-04 21:52
FASTian16-May-04 21:52 
GeneralRe: CListBox scroll bar not getting enabled Pin
David Crow17-May-04 2:17
David Crow17-May-04 2:17 
QuestionCString insertion operator faulty? Pin
Indrawati13-May-04 23:55
Indrawati13-May-04 23:55 
AnswerRe: CString insertion operator faulty? Pin
jmkhael13-May-04 23:59
jmkhael13-May-04 23:59 
AnswerRe: CString insertion operator faulty? Pin
toxcct14-May-04 0:00
toxcct14-May-04 0:00 
AnswerRe: CString insertion operator faulty? Pin
Anand Paranjpe14-May-04 0:46
Anand Paranjpe14-May-04 0:46 

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.