Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
Questionwhy does my application flicker??!!! Pin
Susuko7-May-06 1:26
Susuko7-May-06 1:26 
AnswerRe: why does my application flicker??!!! Pin
Christian Graus7-May-06 1:32
protectorChristian Graus7-May-06 1:32 
QuestionDataGrid problem Pin
narendrakumarp7-May-06 0:19
narendrakumarp7-May-06 0:19 
AnswerRe: DataGrid problem Pin
Robert Rohde7-May-06 3:01
Robert Rohde7-May-06 3:01 
QuestionListing Project Forms Pin
freshonlineMax6-May-06 23:15
freshonlineMax6-May-06 23:15 
AnswerRe: Listing Project Forms Pin
Robert Rohde7-May-06 3:00
Robert Rohde7-May-06 3:00 
GeneralRe: Listing Project Forms Pin
freshonlineMax7-May-06 19:49
freshonlineMax7-May-06 19:49 
QuestionC# equivalent to char * (well, System.IntPtr)?? Pin
Phil C6-May-06 19:15
Phil C6-May-06 19:15 
OK, as usual I'm stuck in transition between my familiar C/C++ background and finding the C# equivalent.

This is really probably first grade stuff, but I've been beating my head for the last hour, reading through my books, help and basic texts and I need to just give up and ask for help getting back on track.

I'm importing a Win32 API function (because there is no .NET equivalent yet) that I need to call in my program. Basically this function requires a pointer. So I need to create a block of memory 2048 bytes long, manipulate it in a string fashion (set it to something) then give the Win32 API a pointer to the memory.

If this were C++ I could bang this out in 2 seconds and be done with it.

void MyFunction( char *astring)
{
    char chunk[2048];
    if(strlen(astring) > 2048)//they gave me too much data, bail out
        return;

    memset(chunk, 0, 2048);//make sure my chunk starts with zeroes
    strcpy( chunk, astring);//copy the data into my chunk
    TheWin32APIFunc( (int *)chunk, 2048 );//the magic function 
      //notice that it requires a int * but a typecast does the trick
}

But this is not C++, I'm in C# managed memory land. c# strings aren't zero terminated, I can't change the length of a string once it's created and c# and .NET really don't want me touching the actual memory directly so just doing a typecast isn't very appreciated by my compiler either.
Anyone feel like taking pity?

TheWin32APIFunc is formatted/prototyped thusly:

private static extern int TheWin32APIFunc( IntPtr data, Int32 datlen);

so I need a System.IntPtr and a plain Int32 (I got the Int32 covered).

Thanks in advance

-- modified at 1:15 Sunday 7th May, 2006
AnswerRe: C# equivalent to char * (well, System.IntPtr)?? Pin
DigitalKing6-May-06 20:29
DigitalKing6-May-06 20:29 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Phil C6-May-06 20:51
Phil C6-May-06 20:51 
AnswerRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Christian Graus6-May-06 20:39
protectorChristian Graus6-May-06 20:39 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Phil C6-May-06 21:07
Phil C6-May-06 21:07 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Christian Graus6-May-06 21:16
protectorChristian Graus6-May-06 21:16 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Phil C6-May-06 21:27
Phil C6-May-06 21:27 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Christian Graus6-May-06 21:44
protectorChristian Graus6-May-06 21:44 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Phil C6-May-06 22:26
Phil C6-May-06 22:26 
GeneralRe: C# equivalent to char * (well, System.IntPtr)?? Pin
Christian Graus7-May-06 1:32
protectorChristian Graus7-May-06 1:32 
GeneralYup...that did the trick...thanx Pin
Phil C6-May-06 23:59
Phil C6-May-06 23:59 
GeneralRe: Yup...that did the trick...thanx Pin
Christian Graus7-May-06 1:34
protectorChristian Graus7-May-06 1:34 
AnswerRe: C# equivalent to char * (well, System.IntPtr)?? Pin
rudy.net7-May-06 3:26
rudy.net7-May-06 3:26 
QuestionDataGrid in ASP.NET App Using C# Pin
kayos5926-May-06 17:10
kayos5926-May-06 17:10 
Questionspeech sdk5.1 Pin
TheEagle6-May-06 16:54
TheEagle6-May-06 16:54 
AnswerRe: speech sdk5.1 Pin
Ravi Bhavnani6-May-06 18:01
professionalRavi Bhavnani6-May-06 18:01 
GeneralRe: speech sdk5.1 Pin
TheEagle6-May-06 22:16
TheEagle6-May-06 22:16 
QuestionOpening PDF file Pin
May Thu san6-May-06 16:36
May Thu san6-May-06 16:36 

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.