Page 1 of 1

Help needed with LDAP structure inside procedure

Posted: Tue Mar 01, 2016 2:15 pm
by TeddyLM
Hi,

I'm currently working with the Windows LDAP library wldap32, and it looks promising so far.
(I'll post my results as soon as i'm ready)

I have a question though.

If i write my code without procedures everything works fine but if i try to separate the elements inside procedures it crashes.

For example, this works:

Code: Select all

Prototype.i Proto_ldap_init(Domain$, PortNumber.l)
LibNr.i = OpenLibrary(#PB_Any, "wldap32.dll")
If LibNr
    CompilerSelect #PB_Compiler_Unicode
        CompilerCase 0       
            LdapInit.Proto_ldap_init = GetFunction(LibNr, "ldap_initA")
        CompilerCase 1   
            LdapInit.Proto_ldap_init = GetFunction(LibNr, "ldap_initW")
    CompilerEndSelect    
Else
    MessageRequester("Error", "Unable to open the LDAP library", 16) : End    
EndIf

*ld = LdapInit("MyDomain", 389) 
Debug *ld
but this doesn't:

Code: Select all

Prototype.i Proto_ldap_init(Domain$, PortNumber.l)
LibNr.i = OpenLibrary(#PB_Any, "wldap32.dll")
If LibNr
    CompilerSelect #PB_Compiler_Unicode
        CompilerCase 0       
            Global LdapInit.Proto_ldap_init = GetFunction(LibNr, "ldap_initA")
        CompilerCase 1   
            Global LdapInit.Proto_ldap_init = GetFunction(LibNr, "ldap_initW")
    CompilerEndSelect    
Else
    MessageRequester("Error", "Unable to open the LDAP library", 16) : End    
EndIf

Procedure.i LDAP_INIT(Domainname$, PortNumber.l)
    *ld = LdapInit(Domainname$, PortNumber.l)
    ProcedureReturn *ld
EndProcedure 

Debug LDAP_INIT("MyDomain", 389)
Do you know what i'm doing wrong!

Thanks for the help
TeddyLM

Re: Help needed with LDAP structure inside procedure

Posted: Tue Mar 01, 2016 2:47 pm
by Julian
Hmmm, works fine here. Try restarting Purebasic if that doesnt fix it try rebooting your computer, I've had a few bugs I cant explain go away from a nice reboot.

Re: Help needed with LDAP structure inside procedure

Posted: Tue Mar 01, 2016 3:19 pm
by TeddyLM
it still crashes with or without Debugger enabled.
I'm using PB 5.42 beta 5 LTS (x86) on Win7 x64

Am i the only one with that problem?

Re: Help needed with LDAP structure inside procedure (solved

Posted: Wed Mar 02, 2016 8:45 am
by TeddyLM
Found it!
i changed the commands 'prototype' to 'prototypeC' and it works.

Thanks

Re: Help needed with LDAP structure inside procedure

Posted: Wed Mar 02, 2016 8:46 am
by mhs
Try PrototypeC, maybe that helps.

Re: Help needed with LDAP structure inside procedure (solved

Posted: Wed Mar 02, 2016 8:46 am
by mhs
TeddyLM wrote:Found it!
i changed the commands 'prototype' to 'prototypeC' and it works.

Thanks
... written at the same time ... :D

Re: Help needed with LDAP structure inside procedure

Posted: Wed Mar 02, 2016 8:49 am
by TeddyLM
Looks like i was faster. :D

Thanks for the hint mhs