Click here to Skip to main content
16,016,477 members
Home / Discussions / C#
   

C#

 
GeneralRe: use the loudspeakers with C# Pin
amityo23-Jul-08 5:28
amityo23-Jul-08 5:28 
GeneralRe: use the loudspeakers with C# Pin
mark_w_23-Jul-08 5:32
mark_w_23-Jul-08 5:32 
GeneralRe: use the loudspeakers with C# Pin
Luc Pattyn23-Jul-08 7:01
sitebuilderLuc Pattyn23-Jul-08 7:01 
GeneralRe: use the loudspeakers with C# Pin
amityo23-Jul-08 13:23
amityo23-Jul-08 13:23 
GeneralRe: use the loudspeakers with C# Pin
Luc Pattyn23-Jul-08 13:44
sitebuilderLuc Pattyn23-Jul-08 13:44 
GeneralRe: use the loudspeakers with C# Pin
amityo23-Jul-08 13:29
amityo23-Jul-08 13:29 
AnswerRe: use the loudspeakers with C#-one more question Pin
amityo23-Jul-08 13:41
amityo23-Jul-08 13:41 
QuestionDLLImport problem Pin
teejayem23-Jul-08 4:35
teejayem23-Jul-08 4:35 
I have an unmanaged dll and I'm trying to make a wrapper around it so it can be used in a multiple projects. I have most of the functions working accept 1 and i can't seem to figure it out.

From the pdf the signature is as follows:
ic_subcall (sub_name, sub_name_len, code, num_args, var_args...)


In the documentation, the last argument is similar to params in C# and it takes type "ICSTRING".
typedef struct icstring {
      long len;
      unsigned char * text;
} ICSTRING;


And here is the method signature in the header file:
void FAR ic_subcall ic_proto((LPSTR, LPLONG, LPLONG, LPLONG, ...));


This is how i have my struct setup in C#. Here i am using a byte[] because i found (somewhere) that it is the equivelant to an unsighed char.
[StructLayout(LayoutKind.Sequential)]
        internal struct icstring
        {
            public long len;
            public byte[] text;
        }



And finally, here is where i using the DLLImport
[DllImport("uvic32.dll", SetLastError = true)]
        private static extern void ic_subcall(string sub_name, long sub_name_len, ref long code, long num_args, params icstring[] var_args);



When i make the call it throws an exception "Attempted to read protected memory....". I can't seem to figure out what is wrong. I'm not sure if it is the params keyword or if my struct is messed up somehow. Could someone point me in the right direction?

Don't be overcome by evil, but overcome evil with good

AnswerRe: DLLImport problem Pin
Luc Pattyn23-Jul-08 4:43
sitebuilderLuc Pattyn23-Jul-08 4:43 
GeneralRe: DLLImport problem Pin
teejayem23-Jul-08 5:01
teejayem23-Jul-08 5:01 
GeneralRe: DLLImport problem Pin
Luc Pattyn23-Jul-08 5:17
sitebuilderLuc Pattyn23-Jul-08 5:17 
GeneralRe: DLLImport problem Pin
teejayem23-Jul-08 6:07
teejayem23-Jul-08 6:07 
AnswerRe: DLLImport problem Pin
led mike23-Jul-08 5:05
led mike23-Jul-08 5:05 
GeneralRe: DLLImport problem Pin
teejayem23-Jul-08 5:17
teejayem23-Jul-08 5:17 
GeneralRe: DLLImport problem Pin
led mike23-Jul-08 6:01
led mike23-Jul-08 6:01 
GeneralRe: DLLImport problem [modified] Pin
teejayem23-Jul-08 6:27
teejayem23-Jul-08 6:27 
GeneralRe: DLLImport problem Pin
led mike23-Jul-08 8:48
led mike23-Jul-08 8:48 
Questionadd data in datarow and fit max length columns Pin
JoZ CaVaLLo23-Jul-08 4:32
JoZ CaVaLLo23-Jul-08 4:32 
AnswerRe: add data in datarow and fit max length columns Pin
JoZ CaVaLLo23-Jul-08 4:46
JoZ CaVaLLo23-Jul-08 4:46 
Questionwin form treeview image Pin
arkiboys23-Jul-08 3:53
arkiboys23-Jul-08 3:53 
AnswerRe: win form treeview image Pin
Luc Pattyn23-Jul-08 4:07
sitebuilderLuc Pattyn23-Jul-08 4:07 
GeneralRe: win form treeview image Pin
arkiboys23-Jul-08 4:11
arkiboys23-Jul-08 4:11 
GeneralRe: win form treeview image Pin
arkiboys23-Jul-08 4:17
arkiboys23-Jul-08 4:17 
GeneralRe: win form treeview image Pin
Luc Pattyn23-Jul-08 4:21
sitebuilderLuc Pattyn23-Jul-08 4:21 
GeneralRe: win form treeview image Pin
arkiboys23-Jul-08 4:24
arkiboys23-Jul-08 4:24 

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.