Xojo Conferences
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

SoftDeclareMBS.CallFunction(param as string,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Calls a function.
Example:
dim c as SoftDeclareMBS
dim m,p,b as memoryBlock
dim f as folderItem
dim path as string

f=ApplicationsFolderMBS(-32766) // get a folder...
path=f.NativePath

MsgBox path

b=newmemoryBlock(1024)
b.long(0)=0 // make empty C string

p=newmemoryBlock(lenb(path)+3)
p.cstring(0)=path

m=newmemoryBlock(12+10)
m.long(0)=p.AddressMBS(0)
m.long(4)=b.AddressMBS(0)
m.long(8)=1023

c=new SoftDeclareMBS
if c.LoadDLL("KERNEL32") then
if c.loadfunction("GetShortPathNameA") then
c.CallingMode=0
MsgBox "found function"
if c.CallFunction("iii",m) then
msgbox "Short path is: "+b.cstring(0)
else
msgbox "Failed to call function."
end if
else
msgbox "Loading of function "+c.FunctionName+" failed."
end if
else
msgbox "Loading of Kernel32 failed."
end if
Notes:
The param string is a combination of the characters "i" for integer, "l" for 64bit integer, "f" for single (float) and "d" for double.
Use "i" for booleans, shorts and pointers.

the memoryblock must match exactly the parameters you specified.
Returns true on success.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallFunction(paramcount as Integer,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin Yes Yes Yes Yes No
Function: Calls a function.
Example:
dim c as SoftDeclareMBS
dim m,p,b as memoryBlock
dim f as folderItem
dim path as string

f=ApplicationsFolderMBS(-32766) // get a folder...
path=f.NativePath

MsgBox path

b=newmemoryBlock(1024)
b.long(0)=0 // make empty C string

p=newmemoryBlock(lenb(path)+3)
p.cstring(0)=path

m=newmemoryBlock(12+10)
m.long(0)=p.AddressMBS(0)
m.long(4)=b.AddressMBS(0)
m.long(8)=1023

c=new SoftDeclareMBS
if c.LoadDLL("KERNEL32") then
if c.loadfunction("GetShortPathNameA") then
c.CallingMode=0
MsgBox "found function"
if c.CallFunction(3,m) then
msgbox "Short path is: "+b.cstring(0)
else
msgbox "Failed to call function."
end if
else
msgbox "Loading of function "+c.FunctionName+" failed."
end if
else
msgbox "Loading of Kernel32 failed."
end if
Notes:
If paramtercount is 0, the memoryblock is ignored.
The size of the memoryblock must be minimum 4*paramcount.
Each parameter is set using m.long(n*4) where n=0 is the first parameter.
A parameter may be any integer value or an address of a memoryblock. The address can be read using memoryblock.addressMBS which is part of the plugin. You can even use only one memoryblock for all 3 parameters in the example like this:

m=newmemoryBlock(2100)
m.cstring(1024)=path
m.long(0)=m.address(20)
m.long(4)=m.address(1024)
m.long(8)=1024

First 12 bytes for the parameter table, the next 1000 bytes for the result buffer and finally a thousand bytes for the input string.

Before RB 3.1 this function was named "Call", but RB5 requires that the word "Call" is no longer valid for a function name.

Softdeclare is limited to only 6 parameters for plugin version 3.2. Plugin version 3.3 extends this to 8 parameters.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallFunctionDouble(param as string,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Calls a function which returns a double value.
Notes:
The param string is a combination of the characters "i" for integer, "l" for 64bit integer, "f" for single (float) and "d" for double.
Use "i" for booleans, shorts and pointers.

the memoryblock must match exactly the parameters you specified.
Returns true on success.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallFunctionDouble(paramcount as Integer,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 3.4 Yes Yes Yes Yes No
Function: Calls a function which returns a double value.
Notes:
Fills the ResultDouble property.

If paramtercount is 0, the memoryblock is ignored.
The size of the memoryblock must be minimum 4*paramcount.
Each parameter is set using m.long(n*4) where n=0 is the first parameter.
A parameter may be any integer value or an address of a memoryblock. The address can be read using memoryblock.addressMBS which is part of the plugin.
Only 10 parameters can currently be used.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallFunctionInteger64(param as string,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Calls a function which returns an integer value.
Notes:
The param string is a combination of the characters "i" for integer, "l" for 64bit integer, "f" for single (float) and "d" for double.
Use "i" for booleans, shorts and pointers.

the memoryblock must match exactly the parameters you specified.
Returns true on success.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallFunctionInteger64(paramcount as Integer,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 3.4 Yes Yes Yes Yes No
Function: Calls a function which returns an integer value.
Notes:
Fills the ResultInt64 property.

If paramtercount is 0, the memoryblock is ignored.
The size of the memoryblock must be minimum 4*paramcount.
Each parameter is set using m.long(n*4) where n=0 is the first parameter.
A parameter may be any integer value or an address of a memoryblock. The address can be read using memoryblock.addressMBS which is part of the plugin.
Only 10 parameters can currently be used.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallMethod(param as string,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Calls a function which returns no value.
Notes:
The param string is a combination of the characters "i" for integer, "l" for 64bit integer, "f" for single (float) and "d" for double.
Use "i" for booleans, shorts and pointers.

the memoryblock must match exactly the parameters you specified.
Returns true on success.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CallMethod(paramcount as Integer,data as memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.1 Yes Yes Yes Yes No
Function: Calls a function which returns no value.
Notes:
If paramtercount is 0, the memoryblock is ignored.
The size of the memoryblock must be minimum 4*paramcount.
Each parameter is set using m.long(n*4) where n=0 is the first parameter.
A parameter may be any integer value or an address of a memoryblock. The address can be read using memoryblock.addressMBS which is part of the plugin.
Only 10 parameters can currently be used.
Returns true on success.

See also:

Feedback, Comments & Corrections

SoftDeclareMBS.CopyLibrary(byref target as SoftDeclareMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Copies the library handle to another softdeclare object.
Notes:
if target is nil, a new object is created.
The library handle in the target object is set to point to the same library as the original object.

Feedback, Comments & Corrections

SoftDeclareMBS.FreeLibrary as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 5.4 No Yes No Yes, Windows only No
Function: Releases the library.
Notes:
Only for Windows currently this function releases the handles and unloads the library. Windows internally has a reference counter for the library so memory is only released when the last reference is freed.
Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadConstant(constname as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin Yes Yes Yes Yes No
Function: Loads a constant from inside the library.
Example:
dim c as SoftDeclareMBS
dim s as CFStringMBS
dim m as MemoryBlock
dim handle as Integer

// Test Mac OS X
// Load the constant kABFirstNameProperty from the Addressbook framework

c=new SoftDeclareMBS

if c.LoadFramework("Addressbook.framework") then
msgbox "Loaded "+c.libname+" to "+format(c.libhandle,"-0")+"."
if c.LoadConstant("kABFirstNameProperty") then
msgbox "Loaded constant "+c.ConstantName+" to "+format(c.ConstantPointer,"-0")+"."

m=NewMemoryBlockFromPtrMBS(c.ConstantPointer) // I hope it's not nil!

handle=m.Long(0)
if handle<>0 then
s=new CFStringMBS
s.Handle=handle

msgbox "Got value: "+s.str
end if
else
msgbox "Loading of constant "+c.ConstantName+" failed."
end if
else
msgbox "Loading of Addressbook.framework failed."
end if
Notes: Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadDLL(libname as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 5.4 No Yes No Yes, Windows only No
Function: Loads a Windows DLL.
Notes:
Lasterror is set.
libname can be name (e.g. "KERNEL32"), filename (e.g. "KERNEL32.DLL") or path (e.g. "C:\WINDOWS\KERNEL32.DLL").

Feedback, Comments & Corrections

SoftDeclareMBS.LoadDLLfromMemory(data as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 No Yes No Yes, Windows only No
Function: Loads a Windows DLL from a string.
Notes:
Some libraries don't like to be loaded from a string.
But else you can pass any DLL file content to this function.

The string is locked so it stays in memory.
On success the handle property is not zero and the function returns true.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadDylib(path as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 5.4 Yes No No Yes, macOS only No
Function: Loads a library in Mac OS X dylib format.
Notes: Lasterror and Liberror are set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadFramework(frameworkfilename as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 5.4 Yes No No Yes, macOS only No
Function: Loads a framework in Mac OS X.
Example:
// A user's question:
// I am trying to call this to Carbon.framework using the softdeclare function:

// UInt32 SwapQDTextFlags(UInt32 newFlags);

// flags are OR'd

// kQDUseDefaultTextRendering = 0
// kQDUseTrueTypeScalerGlyphs = (1 << 0)
// kQDUseCGTextRendering = (1 << 1)
// kQDUseCGTextMetrics = (1 << 2)
// kQDDontChangeFlags = 0xFFFFFFFF

// The call is to make the system use Quartz rendering for QuickDraw text (like the text in my WASTEField). How should I call this?

// The solution code:

dim s as SoftDeclareMBS
dim m as MemoryBlock

const flags=-1 // = 0xFFFFFFFF

s=new SoftDeclareMBS
m=NewMemoryBlock(10)
m.Long(0)=flags

if s.LoadFramework("Carbon.Framework") then
if s.LoadFunction("SwapQDTextFlags") then
if s.CallFunction(1,m) then
MsgBox str(s.Result) // returns 7 for me (using Silk)
end if
end if
end if

// Without any error checking!
Notes:
frameworkfilename is e.g. "Carbon.framework"
Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadFrameworkFile(frameworkpath as folderitem) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 3.2 Yes No No Yes, macOS only No
Function: Loads on Mac OS X a framework from the given file specification.
Example:
dim f as FolderItem
dim s as SoftDeclareMBS

f=SpecialFolder.Desktop.Child("spellcheck.bundle")
s=new SoftDeclareMBS

if s.LoadFrameworkFile(f) then
MsgBox "OK"
end if
Notes:
Returns true if successfull.
Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadFunction(funcname as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin Yes Yes Yes Yes No
Function: Loads a function from inside the library.
Example:
dim s as SoftDeclareMBS
dim m as MemoryBlock

const flags=-1 // = 0xFFFFFFFF

s=new SoftDeclareMBS
m=NewMemoryBlock(10)
m.Long(0)=flags

if s.LoadLibrary("Carbon.Framework") then
if s.LoadFunction("SwapQDTextFlags") then
if s.CallFunction(1,m) then
MsgBox str(s.Result) // returns 7 for me (using Silk)
end if
end if
end if
Notes:
A user's question:
I am trying to call this to Carbon.framework using the softdeclare function:

UInt32 SwapQDTextFlags(UInt32 newFlags);

flags are OR'd

kQDUseDefaultTextRendering = 0
kQDUseTrueTypeScalerGlyphs = (1 << 0)
kQDUseCGTextRendering = (1 << 1)
kQDUseCGTextMetrics = (1 << 2)
kQDDontChangeFlags = 0xFFFFFFFF

The call is to make the system use Quartz rendering for QuickDraw text (like the text in my WASTEField). How should I call this?

The solution code is above without any error checking!

Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.LoadLibrary(libname as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin Yes Yes Yes Yes No
Function: Loads a library.
Notes:
On Mac OS X e.g. "Carbon.framework" or "System.framework".
On Mac OS Carbon inside Classic e.g. "CarbonLib".
On Windows e.g. "KERNEL32" or "USER32".

Lasterror is set.

Feedback, Comments & Corrections

SoftDeclareMBS.ParametersSupported(param as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Declare MBS Util Plugin 7.7 Yes Yes Yes Yes No
Function: Tests whether plugin supports the given parameter string.
Notes:
The param string is a combination of the characters "i" for integer, "l" for 64bit integer, "f" for single (float) and "d" for double.
Use "i" for booleans, shorts and pointers.

Any new parameter string can be added. Please send an email to support to get a new combination added.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.

The biggest plugin in space...




Links
MBS Xojo Plugins