Re: Unmanaged code(dll) function: int myfunc (char* temp)



Rewrite the C library to use TCHAR, since CE is heavily biased that way. If
you *must* use char (and the example makes me doubt it), then you'll have to
bring it back as a byte[] and use the Encoding.ASII class to convert it to a
string.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--



"Murthy" <Murthy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1856CE89-2980-406C-A531-1827CDB428C2@xxxxxxxxxxxxxxxx
C++ code:

int myfunc(char* temp)
{
//Assigning an value to temp
strcpy(temp,L"abcd");

}
I am using char* not TCHAR*

Can you help me how to get the value of temp when using string builder
from managed code



"<ctacke/>" wrote:

Without seeing the code in your C method, there's no way to know what's
wrong.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Murthy" <Murthy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C70DC73E-98B2-481B-BABE-03FDCF1C40B3@xxxxxxxxxxxxxxxx
Hi,
Thanks for ur Reply....
I tried StringBuilder it worked, But there is some problem with
conversion
i
think.
When i tried to convert it to string as sb.Tostring(), it is giving me
some
junk characters which are not alphanumeric.

Can u tell me what i need to do to convert the stringbuilder sb to some
alphanumeric string.

Murthy.

"<ctacke/>" wrote:

First thing to know is that CE doesn't store strings in a char* type,
it
uses UTF16, so they are wchar_t.

If the native DLL will be putting data into that variable, you need to
allocate enough memory for it before the call. The easiest way is
with a
StringBuilder.

int myfunc (TCHAR* temp)
{
.....
}

[DllImport("mylib.dll")]
public static extern int myfunc(StringBuilder sb);

void MyCall()
{
StringBuilder sb = new StringBuilder(255);
int ret = myfunc(sb);
}


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Murthy" <Murthy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5F9D1506-CD19-4390-B633-0BDE53BCC1DA@xxxxxxxxxxxxxxxx
Hi,
I want to do an unmanaged call to an DLL
Unmanaged code(dll) function: int myfunc (char* temp)
Here return int type determines the Success.
After execution of the function temp will contain an value

How to do the unmanaged call to this function from c# and later how
to
retrieve the value from temp, which hold a string value.

thanks in Advance,
Murthy









.



Relevant Pages

  • Re: socket communication: send & receive doesnt work right
    ... So I don't want to send a string as bytes. ... public void send_doubles(double vals, int len) throws ... // send a short acknowledgement to the server ... char *result; ...
    (microsoft.public.win32.programmer.networks)
  • Re: [PATCH] markers: modpost
    ... pointers to the name/format string pairs. ... The same can then be done with modules using the __markers section. ... +static void read_markers(const char *fname) ... int main ...
    (Linux-Kernel)
  • Re: Converting code from single to double precision
    ... int VarHasData; ... void PrintFortranLine (char *s); ... int continuedFormat = FALSE; ... char temp; ...
    (comp.lang.fortran)
  • Re: [PATCH] markers: modpost
    ... This adds some new magic in the MODPOST phase for CONFIG_MARKERS. ... will be a neighbor of its format string. ... +static void read_markers(const char *fname) ... int main ...
    (Linux-Kernel)
  • Re: A string collection abstract data type
    ... duplicate string in Insert, InsertAt, ReplaceAt; ... used int instead of size_t for count and size for consistency with API. ... char *(StringCollection *SC, int idx, ... static int IsReadOnly; ...
    (comp.lang.c)