Code:
//decodejj2t.cs
using System;
using System.Runtime.InteropServices;
unsafe class app
{
char[] input;
char *output;
int CompressedSize;
int UncompressedSize;
static void Main()
{
app a = new app();
a.Decode();
Console.ReadLine();
}
public unsafe void Decode()
{
string (-) = "Let us attempt to compress this string";
input = (-).ToCharArray();
UncompressedSize = input.Length;
CompressedSize = (int)((float)(UncompressedSize * 1.01 ) + 12);
compress2(output, &CompressedSize, input, UncompressedSize, 9);
Console.WriteLine("Done..");
}
[DllImport("zlib.dll")]
static extern long compress(ref object dest, ref object destLen, ref object src, long srcLen);
[DllImport("zlib.dll")]
static extern long compress2( char* dest, int* destLen, char[] src, long srcLen, int Level);
[DllImport("zlib.dll")]
static extern long uncompress(ref object dest, ref object destLen, ref object src, long srcLen);
[DllImport("zlib.dll")]
static extern long crc32(long crc, ref object buffer, long bufferLen);
}
AAh.. Supid formats.. The C# compiler complaints about this error:
decodejj2t.cs(30,20): error CS0212: You can only take the address of an unfixed expression inside of a fixed statement initializer
decodejj2t.cs(30,20): error CS0212: Alleen het adres van een niet-vaste
expressie kan binnen de initialisatiefunctie van een vaste instructie
worden gebruikt
I need to use the keyword "fixed" but.... Where :'(
Last edited by Marijn; Apr 30, 2006 at 01:43 PM.
|