realbasic-nug
[Top] [All Lists]

Re: Windows Declare Help/Crash

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Windows Declare Help/Crash
From: Aaron Ballman <aaron at realsoftware dot com>
Date: Thu, 31 Mar 2005 10:04:10 -0600
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <b4e717880c58604fc1bb5255a5a49747 at nc dot rr dot com>
Declare Function SetOptionValueA Lib "engine.dll"(ByRef Name as cstring, ByRef Value as cstring) as integer
return SetOptionValueA(mb1,mb2)

mb1 & mb2 are memory  blocks, assigned in this manner:
mb1 = newMemoryBlock(1+LenB(sName))
mb2 = newMemoryBlock(1+LenB(sValue))
mb1.cstring(0) = sName
mb2.cString(0) = sValue

It's asking for a ByRef string, which is really a pointer to a string. So you're missing one easy step:

dim strPtrName as new MemoryBlock( 4 )
strPtrName.Ptr( 0 ) = mb1

dim strPtrValue as new MemoryBlock( 4 )
strPtrValue.Ptr( 0 ) = mb2

SetOptionValue( strPtrName, strPtrValue )

Don't forget to turn the ByRef Name as CString into just Name as Ptr (same for Value), and things should work.

HTH!

~Aaron
--
Of course, with the Pentium 3, 1 + 1 <> 2 except for very large values of 2.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>