Ian,
The safest bet in to check with your compiler documentation to see exactly
how it defines "bool". In older version of MS VC, 'bool' was defined the
same size as 'int'. In version 4.2, it was changed to a single char.
Additionally, you could write a simple "Hello, World" program to display the
length of "bool" and use a compatible variable type in VBA. E.g,
long int SizeOfbool()
{
printf("Size Of 'bool' in bytes: %d", sizeof(bool));
return sizeof(bool);
}
If bool is a single byte, use the VBA Byte data type. E.g.,
Public Declare Function ReturnboolLC Lib "TestDLL.dll" () As Byte
Sub AAA()
Dim L As Long ' can be any integral variable type. VBA will convert.
L = ReturnboolLC()
Debug.Print CStr(L)
End Sub
The _stdcall calling convention is a Microsoft-specific option in C. It
isn't supported in ANSI C. Therefore, if you want to call functions in C DLL
from
VB/VBA, you need to write non-ANSI C code. If you need to keep your
procedures ANSI-compatible, you'll need to write an additional DLL that
wraps your ANSI functions up in _stdcall functions and compile that DLL in
VC++. You can read more about __stdcall at
http://msdn.microsoft.com/library/de...___stdcall.asp
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"Ian Kennedy" wrote in message
...
Chip Pearson wrote:
"Chip Pearson" wrote in message
Declare Function SetBootstraps lib "mylib" (ByVal nBootstraps As Long)
As Boolean
Should be
Declare Function SetBootstraps lib "mylib" (ByVal nBootstraps As Long) As
Long
Also, in VC++, there is "BOOL" and "bool", two distinct types: "BOOL" is
a long int (32-bits) and "bool" is a char (8-bits).
I'm not on windows, so BOOL is probably not available. What is Excel VBA
expecting for a boolean return value? It seems to be 16 bit so I could
just use a 'short'.
You can test the difference with
int __stdcall SizeOfBOOLUpperCase()
{
return sizeof(BOOL);
}
int _stdcall SizeOfboolLowerCase()
{
return sizeof(bool);
}
SizeOfBOOLUpperCase returns 4.
SizeOfboolLowerCase returns 1.
Thanks again
Ian