realbasic-nug
[Top] [All Lists]

Returning a string from a c dll to real basic

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Returning a string from a c dll to real basic
From: "Keith Hutchison" <keith dot hutchison at balance-infosystems dot com>
Date: Wed, 31 Aug 2005 18:01:39 +1000
Delivered-to: realbasic-nug at lists dot realsoftware dot com
The following fails, and I am not sure why (yet)

Is this a correct way to send back a string from c ?
export char* _stdcall getCurrentRecordingDevice()
{
 char    deviceName[MIXER_SHORT_NAME_CHARS] = "null";
 /*
   processing to get name works.
 */
 return deviceName ;
}
It compiles

but within rb.

  dim result as MemoryBlock
  result = new MemoryBlock(32)
  #if TargetWin32
    declare Function getCurrentRecordingDevice Lib "WinM" Alias
"_getCurrentRecordingDevice at 0" () As Ptr
    result = getCurrentRecordingDevice // the memoryblock gets clobbered
  #endif
  Return result.CString(0)

What is the best way to return a string from a dll to realbasic?

Keith

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>