Can you try casting your string to a c char?
(*C.char)(unsafe.Pointer(string))

On Mon, Aug 6, 2018, 18:54 Amit Limaye <amit.lim...@gmail.com> wrote:

> the dll exported function signature takes a const char *
> while I am passing a string
> my golang call signature
>
> Open(lazyP*syscall.LazyProc, filter string, layer uint32, priority
> int16, flags uint64) error
>
> which I use to make this call
> r1, r2, lastError :=
> lazyP.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(filter))),
>   uintptr(layer),
>   uintptr(priority),
>   uintptr(flags),
>  )
>
> and my dll exported func signature is
>
> HANDLE Open(const char *filter,DIVERT_LAYER layer,
>     INT16 priority, UINT64 flags)
>
>
> -SIGTERM
> amit
>
> Humanity's first sin was faith, Its first virtue doubt
> On Mon, Aug 6, 2018 at 8:49 AM Oryan Moshe <iamoryanmo...@gmail.com>
> wrote:
> >
> > It doesn't look like you turn it to const anywhere, just a pointer. Is
> the pointer conversion returning a const?
> >
> > On Mon, Aug 6, 2018, 18:46 Amit Limaye <amit.lim...@gmail.com> wrote:
> >>
> >> is the const char * a problem my string is not passed as const  ?
> >> -SIGTERM
> >> amit
> >>
> >> Humanity's first sin was faith, Its first virtue doubt
> >>
> >> On Mon, Aug 6, 2018 at 8:33 AM <amit.lim...@gmail.com> wrote:
> >> >
> >> > layer is an enum in the dll.
> >> > Gets converted to uint32 inside the dll before it makes the windows
> api call.
> >> > priority is exposed as int16 in the exported dll api
> >> >
> >> > Regards
> >> > Amit
> >> >
> >> >
> >> > On Saturday, August 4, 2018 at 10:53:40 AM UTC-7, Oryan Moshe wrote:
> >> >>
> >> >> Seems to me like type issues as well, doesn't seem like it for
> winapi to receive int16.
> >> >>
> >> >> On Sat, Aug 4, 2018, 07:18 <amit....@gmail.com> wrote:
> >> >>>
> >> >>> I am trying to call a DLL from go and I get an error "The parameter
> is incorrect" error when I try to call this function
> >> >>>
> >> >>> HANDLE  Myopen(const char *filter, LAYER layer, INT16 priority,
> UINT64 flags)
> >> >>>
> >> >>> is my signature in the C file
> >> >>>
> >> >>> I call from golang using this
> >> >>>
> >> >>> Open(lazyP*syscall.LazyProc, filter string, layer int16, priority
> uint16, flags uint64) error {
> >> >>>  r1, r2, lastError :=
> lazyP.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(filter))),
> >> >>>   uintptr(layer),
> >> >>>   uintptr(priority),
> >> >>>   uintptr(flags),
> >> >>>  )
> >> >>>
> >> >>>  fmt.Println("LastError", lastError)
> >> >>>
> >> >>>  fmt.Println("R1", r1)
> >> >>>
> >> >>>  fmt.Println("R2", r2)
> >> >>>
> >> >>>  return nil
> >> >>> }
> >> >>>
> >> >>> What am I missing here. This is the first time I am trying to load
> windows dlls so a little confused about what am I missing here
> >> >>>
> >> >>>
> >> >>> Regards
> >> >>> Amit
> >> >>>
> >> >>>
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> >> >>> To unsubscribe from this group and stop receiving emails from it,
> send an email to golang-nuts...@googlegroups.com.
> >> >>> For more options, visit https://groups.google.com/d/optout.
> >> >
> >> > --
> >> > You received this message because you are subscribed to a topic in
> the Google Groups "golang-nuts" group.
> >> > To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/o1epszOy544/unsubscribe.
> >> > To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> >> > For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to