C Struct

C Struct

Postby patdriscoll » 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
User avatar
patdriscoll
 
Posts: 16
Joined: Tue May 19, 2009 7:28 pm

Re: C Struct

Postby Antonio Linares » Wed Jun 11, 2014 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct

Postby patdriscoll » Wed Jun 11, 2014 6: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
User avatar
patdriscoll
 
Posts: 16
Joined: Tue May 19, 2009 7:28 pm

Re: C Struct

Postby Antonio Linares » Wed Jun 11, 2014 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct

Postby patdriscoll » Wed Jun 11, 2014 8: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
User avatar
patdriscoll
 
Posts: 16
Joined: Tue May 19, 2009 7:28 pm

Re: C Struct

Postby cnavarro » Wed Jun 11, 2014 8: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
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: C Struct

Postby Antonio Linares » Wed Jun 11, 2014 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct

Postby Enrico Maria Giordano » Thu Jun 12, 2014 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: C Struct

Postby Antonio Linares » Fri Jun 13, 2014 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct

Postby Enrico Maria Giordano » Fri Jun 13, 2014 9:56 am

Antonio,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: C Struct

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: C Struct

Postby Antonio Linares » Fri Jun 13, 2014 10:25 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct

Postby Enrico Maria Giordano » Fri Jun 13, 2014 10:33 am

Antonio,

thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: C Struct

Postby cnavarro » 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
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: C Struct

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 15 guests