Hello George,
To test this I created another function in the DLL:
LPDWORD WINAPI vbNullPointer ()
{
return NULL;
}
then I call the existing function with this new function as a parameter :
MsgBox "test 1 :" & fnTest(vbNullPointer())
The result is 1, which means that it does not work, eVB and NSB seem
to convert the return value into a long, i.e. to 0 which is not the
same as NULL...
Still no go.
--- In [email protected], "George Henne" <g...@...> wrote:
>
> I can't run a test on this here right now, but what happens if you
> modify your DLL to return the value of NULL?
>
>
> >Hi,
> >
> >Thanks for your answer Joe,sorry to say it doesn't work.
> >
> >To investigate the problem I have now created a small dll in eVC with
> >the following code :
> >----------------------
> >DWORD WINAPI fnTest (DWORD *lpTest)
> >{
> > if (lpTest == NULL)
> > {
> > return 0;
> > }
> > else
> > {
> > return 1;
> > }
> >}
> >-----------------------
> >So the function simply checks if the value (a pointer to a long) is
> >NULL and in that case returns 0, else 1
> >
> >Then I call this function from eVB or NSB with the following code :
> >
> >-----------------------
> >Option Explicit
> >Declare Function fnTest Lib "test.DLL" (ByRef lpTest As Long) As Long
> >
> >Private Sub Command1_Click()
> >Dim testlng
> > testlng = CLng(0)
> > On Error Resume Next
> > MsgBox "test 1 :" & fnTest(0)
> > MsgBox "test 2 :" & fnTest(testlng)
> > MsgBox "test 3 :" & fnTest(Null)
> > MsgBox "test 4 :" & fnTest(vbNull)
> > MsgBox "test 5 :" & fnTest(vbNullString)
> > MsgBox "test 6 :" & fnTest(vbnullptr)
> >End Sub
> >------------------------
> >
> >Result is that ONLY the last msgbox (test6) returns 0 in eVB, all
> >other calls return 1.
> >That means that the vbNullPtr constant is needed to give the lpTest
> >parameter the value NULL as recognized by C.
> >
> >There seems to be no way to get this result in NS Basic as there is
> >no vbnullptr constant there.
> >
> >As I have lots and lots of APIs and DLL functions to use in my
> >planned project, and some parameters are required to be NULL, is
> >there any chance of enhancing NS Basic to be able to do this ?
> >
> >If someone wants to test I can post the above DLL.
> >
> >Thanks for your help...
> > Jingjok
> >
> >
> >
> >--- In [email protected], "joespan123" <joes@> wrote:
> >>
> >> I searched google and can not really find anything but snippets of
> >> what vbNullPtr is supposed to be used for, that is:
> >>
> >> "vbNullPtr Constant: The constant vbNullPtr should be used only for
> >> ByRef parameters."
> >>
> >> Given that a variable to a subroutine is a ByRef by default, that
> >is a
> >> pointer, see if the following code snippet may work.
> >>
> >> Public Const vbNullPtrDef = 0
> >>
> >> Sub RZipInitWrapper(ByVal FirstArg, ByRef vbNullPtrVar)
> >>
> >> Call RZipInit(FirstArg, vbNullPtrVar)
> >>
> >> End Sub
> >>
> >> Call RZipInitWrapper(57236465, vbNullPtrDef)
> >>
> >> or try
> >>
> >> Dim MyLong
> >> MyLong = CLong(0)
> >>
> >> Call RZipInitWrapper(57236465, MyLong)
> >>
> >> I do not know if this will work or not as I do not have a DLL to
> >test
> >> it on.
> >>
> >> Regards
> >> Joe
> >>
> >>
> >> --- In [email protected], "jingjok67" <jingjok67@> wrote:
> >> >
> >> > Hi,
> >> >
> >> > No, that does not work either. It seems nothing (I tried in eVB,
> >too)
> >> > except vbNullPtr works. Looks like anything else is still a
> >variant
> >> > and vbNullPtr is converted by eVB into something special.
> >> >
> >> > It looks like the function I am trying to call is badly written
> >and
> >> > does not accept 0 instead of NULL. This problem hopefully does not
> >> > occur with APIs as they accept 0 instead of NULL ? Does anyone
> >have
> >> > experience with this ?
> >> >
> >> > The only workaround I can think of is to write a C DLL to wrap the
> >> > functions that use null pointers, which is quite ugly and I do not
> >> > really want to do that.
> >> >
> >> > Any chance to include vbNullPtr in NS Basic ?
> >> >
> >> > In the meantime - is there any other ZIP compression library that
> >> > works with NS Basic ?
> >> >
> >> > Thanks for your help.
> >> >
> >> >
> >> >
> >> > --- In [email protected], "George Henne" <gh@> wrote:
> >> > >
> >> > > Can you give this a try?
> >> > >
> >> > > vbNullPtr = clng(0)
> >> > > Call RZipInit (57236465, vbNullPtr)
> >> > >
> >> > > I have no idea if this will work, but the first line forces the
> >> subtype
> >> > > of vbNullPtr to be a long, which may help.
> >> > >
> >> > > >Hello George,
> >> > > >
> >> > > >That is strange, if I try the line
> >> > > >
> >> > > >Msgbox typename(vbNullPtr) & " " & vbNullPtr
> >> > > >
> >> > > >in eVB and run the code I get an error that variable vbNullPtr
> >is not
> >> > > >defined. But then when I use the vbNullPtr in a declared
> >function
> >> > > >call, it works ! I have triple-checked and did not make a
> >writing
> >> > mistake.
> >> > > >
> >> > > >It looks like eVB is only accepting this constant as a
> >parameter for
> >> > > >declared functions.
> >> > > >
> >> > > >What I am trying to do is to use the Resco ZIP DLL, here is the
> >> sample
> >> > > >code (NS Basic) :
> >> > > >
> >> > > >Option Explicit
> >> > > >
> >> > > >Declare "Sub RZipInit Lib ""RZip.dll"" (ByVal uCode As Long,
> >ByRef
> >> > > >lpCallbackFunc As Long)"
> >> > > >
> >> > > >Call RZipInit (57236465, vbNullPtr)
> >> > > >
> >> > > >This code works fine in eVB but NS Basic gives me an error that
> >> > > >vbNullPtr is not defined.
> >> > > >
> >> > > >I have then done further testing in eVB and NS Basic and found
> >that I
> >> > > >cannot substitute vbNullPtr with anything else, i.e. Null,
> >nothing,
> >> > > >vbNull, 0, vbNullString, vbNullChar. In that case the code
> >runs but
> >> > > >the function fails. ONLY vbNullPtr works. I guess that is the
> >reason
> >> > > >why Microsoft added the vbNullPtr in the first place.
> >> > > >
> >> > > >It looks like the code in the RZipInit dll checks this
> >parameter for
> >> > > >NULL (as in C++), i.e.
> >> > > >if (param2 == NULL) DoSomething
> >> > > >The dll call obviously converts anything except vbNullPtr to
> >> something
> >> > > >else than NULL (as defined in C)
> >> > > >
> >> > > >
> >> > > >Then... is there any way to use or substitute vbNullPtr in NS
> >> Basic or
> >> > > >any other trick to make this work ?
> >> > > >
> >> > > >Thanks for your help.
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >--- In [email protected], "George Henne" <gh@> wrote:
> >> > > >>
> >> > > >> My copy of eVB has decided it does not want to work anymore,
> >so I
> >> > can't
> >> > > >> try this here at the moment.
> >> > > >>
> >> > > >> Write a short eVB program that does
> >> > > >>
> >> > > >> Msgbox typename(vbNullPtr) & " " & vbNullPtr
> >> > > >>
> >> > > >> Hopefully, that will give the answer. Let us know, so we can
> >add
> >> > this to
> >> > > >> the Tech Note.
> >> > > >>
> >> > > >> >Hi,
> >> > > >> >
> >> > > >> >I need to call an function in a dll with a vbNullPtr (this
> >is
> >> > > >> >pre-defined in eVB) value in a parameter. What is the
> >> substitute for
> >> > > >> >vbNullPtr in NS Basic ? I tried Null but that did not work.
> >> > > >> >
> >> > > >> >Thanks !
> >> > > >> >
> >> > > >> >
> >> > > >> >------------------------------------
> >> > > >> >
> >> > > >> >Yahoo! Groups Links
> >> > > >> >
> >> > > >> >
> >> > > >> >
> >> > > >>
> >> > > >
> >> > > >
> >> > > >
> >> > > >------------------------------------
> >> > > >
> >> > > >Yahoo! Groups Links
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> >
> >
> >
> >------------------------------------
> >
> >Yahoo! Groups Links
> >
> >
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nsb-ce" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nsb-ce?hl=en
-~----------~----~----~----~------~----~------~--~---