FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour C Struct
Posts: 16
Joined: Tue May 19, 2009 07:28 PM
C Struct
Posted: Wed Jun 11, 2014 11:42 AM

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

Pat Driscoll

Australia
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C Struct
Posted: Wed Jun 11, 2014 05:42 PM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 16
Joined: Tue May 19, 2009 07:28 PM
Re: C Struct
Posted: Wed Jun 11, 2014 06:46 PM

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.

Pat Driscoll

Australia
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C Struct
Posted: Wed Jun 11, 2014 07:32 PM

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 :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 16
Joined: Tue May 19, 2009 07:28 PM
Re: C Struct
Posted: Wed Jun 11, 2014 08:09 PM

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.

Pat Driscoll

Australia
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: C Struct
Posted: Wed Jun 11, 2014 08:18 PM

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

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C Struct
Posted: Wed Jun 11, 2014 08:39 PM
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.zip

Please 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#p160199

You will not notice at all that you are using a C compiler to generate the harbour OBJs :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: C Struct
Posted: Thu Jun 12, 2014 07:28 PM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C Struct
Posted: Fri Jun 13, 2014 09:09 AM

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 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: C Struct
Posted: Fri Jun 13, 2014 09:56 AM

Antonio,

thank you! I'll try Harbour again. :-)

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: C Struct
Posted: Fri Jun 13, 2014 10:05 AM

I am not able to locate hbole.ch in habour\include folder.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: C Struct
Posted: Fri Jun 13, 2014 10:25 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: C Struct
Posted: Thu Jun 19, 2014 11:07 AM
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#p152620

No entiendo en qué tipo de parámetros se puede usar
I do not understand what kind of parameters can be used
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: C Struct
Posted: Thu Jun 19, 2014 11:49 AM
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#p152620

No 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