Re: Help please with pointers to callbacks in structs
From: BMermuys (someone_at_someone.com)
Date: 04/10/04
- Next message: Jon Skeet [C# MVP]: "Re: Installer Auto Run"
- Previous message: Jon Skeet [C# MVP]: "Re: C# Language Proposal for 'out' Parameters"
- Maybe in reply to: BMermuys: "Re: Help please with pointers to callbacks in structs"
- Next in thread: Brian: "Re: Help please with pointers to callbacks in structs"
- Reply: Brian: "Re: Help please with pointers to callbacks in structs"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 10 Apr 2004 13:38:40 +0200
Hi,
<Brian> wrote in message news:107e8o8d2c2432d@corp.supernews.com...
> Hi,
>
> <snip>
> I suppose that I could also use import sprintf or some other function and
> use the pointer with that. Correct? If so, based on your other code that
> you've provided, I think I've got that one covered.
You could use sprintf (c/c++ runtime) but there is a difference in calling
convention, sprintf uses __cdecl. You can call it from c# but you can't
have variable arguments therefore all arguments must be declared eg :
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int sprintf(IntPtr pDest, String format, int i, String
s);
And I don't think you need it, you can use .Net formatting capabilities :
string s = Format( "{0} {1}", 10, "test" ); // eg
lstrcpyA( pData, s );
>
> Out of morbid curiosity, any particular reason why C# is so 'protective'
It's not just c#, all net languages compile to ilasm where most of the
restrictions come from.
The idea is to produce more secure and stable applications.
> of its data? In the land of C (sort of a contradiction there,
> phonetically speaking), it's possible to do just about anything to
> anybody.
Altough I like c it leads to hard to find bugs.
>C# seems to want keep a tight reign of its data. I'm assuming
> its for security reasons, but it sure makes it rough on the 'die-hard' C
> programmers.
You should just forget about pointers when you use c# and learn the class
library which has a lot of functionality.
hth,
Greetings
- Next message: Jon Skeet [C# MVP]: "Re: Installer Auto Run"
- Previous message: Jon Skeet [C# MVP]: "Re: C# Language Proposal for 'out' Parameters"
- Maybe in reply to: BMermuys: "Re: Help please with pointers to callbacks in structs"
- Next in thread: Brian: "Re: Help please with pointers to callbacks in structs"
- Reply: Brian: "Re: Help please with pointers to callbacks in structs"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|