how to perform memset?

  • Thread starter Thread starter Daimy
  • Start date Start date
how to do this by C# ?
byte[] buffer=new byte[8192];

memset(buffer, 'U', 8192);

Have a look at the RtlFillMemory() API call (which AFAIK simply calls memset() or the equivalent of):

'***
Private Declare Function RtlFillMemory Lib "Kernel32.dll" ( _
ByRef Destination As Any, ByVal Length As Long, ByVal Fill As Byte) As Long

....

Const BufSize As Long = 8192

Dim buffer(0 to (BufSize - 1)) As Byte
Call RtlFillMemory(buffer(0), BufSize, Asc("U"))
'***

Note; this is a VB (Classic) solution, if you're after a VB.NET solution then you're in the wrong place; try the groups here:
Http://EDais.mvps.org/DotNet/
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: (e-mail address removed)
WWW: Http://EDais.mvps.org/
 
Thanks!

But why .NET doesn't provide methods like that? :(



Mike D Sutton said:
how to do this by C# ?

byte[] buffer=new byte[8192];

memset(buffer, 'U', 8192);

Have a look at the RtlFillMemory() API call (which AFAIK simply calls
memset() or the equivalent of):

'***
Private Declare Function RtlFillMemory Lib "Kernel32.dll" ( _
ByRef Destination As Any, ByVal Length As Long, ByVal Fill As Byte) As
Long

...

Const BufSize As Long = 8192

Dim buffer(0 to (BufSize - 1)) As Byte
Call RtlFillMemory(buffer(0), BufSize, Asc("U"))
'***

Note; this is a VB (Classic) solution, if you're after a VB.NET solution
then you're in the wrong place; try the groups here:
Http://EDais.mvps.org/DotNet/
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: (e-mail address removed)
WWW: Http://EDais.mvps.org/
 
But why .NET doesn't provide methods like that? :(

I seem to recall reading somewhere that you need to 'pin' the memory before reading from/writing to it at which point you can use
interop to call the same API call, you'll likely get more information on the specifics on a VB.NET group.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: (e-mail address removed)
WWW: Http://EDais.mvps.org/
 
Back
Top