Page 1 of 2
C Struct
Posted: Wed Jun 11, 2014 11:42 am
by patdriscoll
Hello,
I am developing with xHarbour(version dated 17/11/2-11 from xHarbout.com and Fivewin for Harbour. I realise this is an xHarbour issue rather than a Fivewin issue, but I am hoping someone on this forum can help me.
I am trying to get DLLCAL() working wit little to no success. My sample code and (what it returns) can be seen below. All numbers are zero and the string is blank.
Any suggestions or help would be appreciated.
Cheers,
Pat Driscoll
#include "CStruct.ch" // required for "typedef struct"
#include "Wintypes.ch" // required Windows C data types
pragma pack(4) // all Windows API structures
// are 4 byte aligned
// structure declaration taken via
// copy&paste from Windows SDK
typedef struct _OSVERSIONINFOEX { ;
DWORD dwOSVersionInfoSize; // ˆ this ";" must be added
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[128];
WORD wServicePackMajor;
WORD wServicePackMinor;
WORD wSuiteMask;
BYTE wProductType;
BYTE wReserved;
} OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX;
#define DC_CALL_STD 0x0020
PROCEDURE Main()
LOCAL oVerInfo
// Create OSVERSIONINFOEX structure object
oVerInfo := (struct OSVERSIONINFOEX)
// assign structure size to structure member
oVerInfo:dwOSVersionInfoSize := oVerInfo:sizeOf()
// pass structure object by reference to DllCall()
// (it is an OUT parameter)
DllCall( "Kernel32.dll", DC_CALL_STD , "GetVersionEx", @oVerInfo )
// display result of API
MsgInfo(str(oVerInfo:dwMajorVersion)) // result: 0
MsgInfo(str(oVerInfo:dwMinorVersion)) // result: 0
MsgInfo(str(oVerInfo:dwBuildNumber)) // result: 0
// this member contains a byte array
// retrieve it as character string
MsgInfo(oVerInfo:szCSDVersion:asString()) // result: blank spaces
RETURN
Re: C Struct
Posted: Wed Jun 11, 2014 5:42 pm
by Antonio Linares
Pat,
Please try to build it NOT linking the FWH libraries.
It may be a function conflict name due to the versions that you are using.
Re: C Struct
Posted: Wed Jun 11, 2014 6:46 pm
by patdriscoll
Hi Antonio,
Thanks for your reply.
I compiled a DOS version of just the PRG (renaming the FWH folder to fool xBuildW that there was no Fivewin installed). I replace? the MsgInfo() with ? and I get the same result.
I have managed to call other DLLs successfully in the past, but not using cStructures (this was using the exact same versions of xHB and FWH). The bigger picture is that I am interfacing to a Digital Persona bioscan SDK and was having troubles, so went back to a documented example using c Structures as parameters.
Interestingly I made some calls to the GetTimeZoneInformation function of kernel32.dll and was able to get meaningful returns only for StandardName and DaylightName. Other things like StandardDate:wHour, for example return 0 as well.
I am confused.
Cheers,
Pat.
Re: C Struct
Posted: Wed Jun 11, 2014 7:32 pm
by Antonio Linares
Pat,
Based on your results, to me it seems as a xharbour bug. I suggest you to contact xhb.com and report it to them. We can't help you on that, sorry.
Why don't you create an import library from the DLL that you need to manage and then use direct link using some C wrappers ? Its very easy and you have the FWH sources at winapi folder plenty of examples

If you need help just say it.
Also I take the oportunity to insist that you (all of you) migrate to Harbour (many readers will say here: "oh, Antonio again on the same") but Harbour is rock solid , with a growing ang growing users base, and you will be happier and we will have less tech support

Re: C Struct
Posted: Wed Jun 11, 2014 8:09 pm
by patdriscoll
Hi Antonio,
Thanks again for your reply and advice.
So you are advising that I move from xHarbour to Harbour, yes? I am open to this advice, but I am not a C programmer. For me using xHB.com was a cheater's way of remaining C illiterate when I moved from Clipper, thus allowing me to focus on delivering client applications. Lazy, I know.
My biggest concern is the many applications I have that are using Fivewin/xHB. By moving to Fivewin/Harbour, what will I lose? I know there is more to gain you say

.
Anyway I am going to give it a go. Can you point me to a "getting started document" to download harbour and comile one of my existing programs, please?
Thanks again, Antonio.
Cheers,
Pat.
Re: C Struct
Posted: Wed Jun 11, 2014 8:18 pm
by cnavarro
In the forum you will find many examples of the use of harbour: mak, bat, etc., also included in the distribution FWH faith.
Also:
http://harbour.github.io/faq/index.html
Re: C Struct
Posted: Wed Jun 11, 2014 8:39 pm
by Antonio Linares
Pat,
You can download the most recent Harbour for Borland that we have published from here:
https://code.google.com/p/harbour-and-xharbour-builds/downloads/detail?name=harbour_bcc582_20131007.zipPlease send me an email and I will explain you where to download Borland bcc582
To build your app, you just need this two go.bat and test.mak file:
viewtopic.php?p=160199#p160199You will not notice at all that you are using a C compiler to generate the harbour OBJs

Re: C Struct
Posted: Thu Jun 12, 2014 7:28 pm
by Enrico Maria Giordano
Antonio,
Antonio Linares wrote:Also I take the oportunity to insist that you (all of you) migrate to Harbour (many readers will say here: "oh, Antonio again on the same") but Harbour is rock solid , with a growing ang growing users base, and you will be happier and we will have less tech support

Any news regarding OleDefaultArg() function in Harbour?
EMG
Re: C Struct
Posted: Fri Jun 13, 2014 9:09 am
by Antonio Linares
Enrico,
Finally (thanks to Przemek)
#include "hbole.ch"
#define WIN_DISP_E_PARAMNOTFOUND ( 0x80020004L )
function OleDefaultArg()
return __oleVariantNew( WIN_VT_ERROR, WIN_DISP_E_PARAMNOTFOUND )
Re: C Struct
Posted: Fri Jun 13, 2014 9:56 am
by Enrico Maria Giordano
Antonio,
thank you! I'll try Harbour again.

EMG
Re: C Struct
Posted: Fri Jun 13, 2014 10:05 am
by nageswaragunupudi
I am not able to locate hbole.ch in habour\include folder.
Re: C Struct
Posted: Fri Jun 13, 2014 10:25 am
by Antonio Linares
Re: C Struct
Posted: Fri Jun 13, 2014 10:33 am
by Enrico Maria Giordano
Antonio,
thank you.
EMG
Re: C Struct
Posted: Thu Jun 19, 2014 11:07 am
by cnavarro
Enrico Maria Giordano wrote:Antonio,
Antonio Linares wrote:Also I take the oportunity to insist that you (all of you) migrate to Harbour (many readers will say here: "oh, Antonio again on the same") but Harbour is rock solid , with a growing ang growing users base, and you will be happier and we will have less tech support

Any news regarding OleDefaultArg() function in Harbour?
EMG
Enrico
You can give an example of using this function OleDefaultArg ()?
Puedes poner un ejemplo de uso de esta funcion OleDefaultArg()?
I found this link
viewtopic.php?f=3&t=27404&hilit=OleDefaultArg&start=30#p152620No entiendo en qué tipo de parámetros se puede usar
I do not understand what kind of parameters can be used
Re: C Struct
Posted: Thu Jun 19, 2014 11:49 am
by Enrico Maria Giordano
Cristobal,
cnavarro wrote:You can give an example of using this function OleDefaultArg ()?
Puedes poner un ejemplo de uso de esta funcion OleDefaultArg()?
I found this link
viewtopic.php?f=3&t=27404&hilit=OleDefaultArg&start=30#p152620No entiendo en qué tipo de parámetros se puede usar
I do not understand what kind of parameters can be used
It is in the link you reported.
EMG