Re: C_func problems...
- Posted by Greg Haberek <ghaberek at gmail.com> Nov 25, 2004
- 569 views
NULL should be 0, not -1 -1 is sent to a C function as #FFFFFFFF and it thinks that's a memory address (pointer) of a the structure LPSECURITY_ATTRIBUTES. 0, on the other hand, is an empty memory address. On Thu, 25 Nov 2004 17:04:10 +1100, Patrick Barnes <mrtrick at gmail.com> wrote: > > Can anybody tell me why the following code has a machine-level > exception error when run? > > The relevant msdn entry is here: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createmutex.asp > > Very frustrating... > > }}} <eucode> > constant NULL = -1 > include dll.e > include machine.e > constant kernel32 = open_dll("kernel32") > --HANDLE CreateMutex( > -- LPSECURITY_ATTRIBUTES lpMutexAttributes, > -- BOOL bInitialOwner, > -- LPCTSTR lpName > --); > constant xCreateMutex = define_c_func(kernel32, "CreateMutexA", > {C_POINTER, C_CHAR, C_POINTER}, C_INT ) > > function createMutex(sequence name) > atom ret, str > str = allocate_string(name) > ret = c_func(xCreateMutex, {NULL, 0, str}) > free(str) > return ret > end function > > ? createMutex("testing") > </eucode> {{{ > > -- > MrTrick > >