FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour DLL functions usage in Win 7
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
DLL functions usage in Win 7
Posted: Tue Jun 29, 2010 12:54 PM
I have the strange problem working on Windows 7
1. Have the latest xHarbour Professional
2. Bought FWH 8.11 (but the problem is the same with older FWH either)

If I compile the code as in point 1. using Windows XP OS, everything is normal, as for years now
Also, the same program copied on Windows 7 machine, also works normal!

If I compile on Windows 7 environment, I must use the code as in point 2. Otherwise it will hang up the program!!!
The compilation itself went ok, no problem reported, only when the program tries to use and DLL function as in point 1. it hans up.


Anyone can help me to understand this. My programs use many DLLs to work with, starting with PDF managenent, Mail sending, Internet etc...
Seems I might reprogram the DLLs accessing code, to be able to compile it in Windows 7.
Now, I am using Virtualization and am compiling on "XP Mode" but this seems ridiculous, using the OLD system to be able to work?

The way xHarbour or FWH handle the DLLs calls, seems to be different in Windows 7 than in XP
This is definitely and I tested on sveral combinations. The point 1. DLL functions access doesn't work in Windows 7!!
Have no idea why but is very annoying.

I will appreciate any help or clue


Code (fw): Select all Collapse
// 1. THIS DOESN'T WORK WHEN COMPILED ON Windows 7 !!!
-----------------------------------------------------------------------
hDLL := LoadLibrary("iSEDQuickPDF.dll")
IF hDLL < 33
    MsgInfo("Problem reading 'iSEDQuickPdf.dll'")
    RETURN NIL
ENDIF
cFarProc := GetProcAddress(hDLL, "iSEDUnlockKey",.T.,LONG,       STRING)
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX""  // This is the UNLOCK key (not real of course
r := CallDLL( cFarProc,cString)
IF r == 0
    FreeLib32( hDLL )
    MsgInfo("Cannot verify the PassKey !")
    RETURN NIL
ENDIF

// 2. THIS WORKS PERFECT WHEN COMPILED ON Windows 7 !!!
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"   
r := PDF_Connect( cString )

DLL Function PDF_Connect(wString AS  STRING)) AS LONG PASCAL FROM "iSEDUnlockKey" LIB "iSEDQuickPdf.dll"
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: DLL functions usage in Win 7
Posted: Fri Jul 02, 2010 12:00 AM
Nobody is compiling on Windows 7 OS and also using the programs that uses DLL functions??

Nobody has problems using this syntax:
cFarProc := GetProcAddress(hDLL, "iSEDUnlockKey",.T.,LONG, STRING)
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"" // This is the UNLOCK key (not real of course
r := CallDLL( cFarProc,cString)

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: DLL functions usage in Win 7
Posted: Fri Jul 02, 2010 12:30 AM
Boris,

Please place some MsgInfo() traces in your code to locate where it hangs:
Code (fw): Select all Collapse
hDLL := LoadLibrary("iSEDQuickPDF.dll")
MsgInfo( 1 )
IF hDLL < 33
    MsgInfo("Problem reading 'iSEDQuickPdf.dll'")
    RETURN NIL
ENDIF
MsgInfo( 2 )
cFarProc := GetProcAddress(hDLL, "iSEDUnlockKey",.T.,LONG,       STRING)
MsgInfo( 3 )
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"  // This is the UNLOCK key (not real of course
r := CallDLL( cFarProc,cString)
MsgInfo( 4 )
IF r == 0
    FreeLib32( hDLL )
    MsgInfo("Cannot verify the PassKey !")
    RETURN NIL
ENDIF
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: DLL functions usage in Win 7
Posted: Sun Jul 04, 2010 09:33 PM
Antonio,
I already did this as the forst thing to detect where is the problem.
it hags on every place where I call
n = CallDLL(cFarProc, c3)
for example.

I must say that this kind of call when compiled on Windows 7 OS will NOT work!!!
I am using one DLL which controls the dongle attached in USB port to secure my program.
Using about 20 functions from the DLL I now have to replace the sequence with "GHetProcAddress() -> CallDLL()" with the call directly to the function in DLL
I changed the lines of code and now I can compile AND run the same code on XP or Windows 7 OS

Thre DLLs which causes problem I am using are:
IsedQuicPDF.DLL (PDF manipulation and creation)
MpiWin32.dll (Marx USB Dongle)
See32.DLL (mail sending)

For each of these DLL function I had to use different way of calling (other than CallDLL(), then everything works nice

I think you should pay a serious attention to this issue, because more and more people will move to Windows 7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: DLL functions usage in Win 7
Posted: Sun Jul 04, 2010 09:44 PM

Boris,

We use Windows 7 since the very early published betas by Microsoft. Actually it is the only Windows version that we use in our company.

And we use the DLL FUNCTION command in many places from the FWH code and we don't get those errors.

There must be a reason for it. Maybe those DLLs have something special.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: DLL functions usage in Win 7
Posted: Sun Jul 04, 2010 09:46 PM

Boris,

Please notice that in recent FWH builds, we renamed CallDll() into FWCallDll() as Harbour implemented a function CallDll().

Please try to rename your CallDll() calls with FWCallDll(), thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: DLL functions usage in Win 7
Posted: Sun Jul 04, 2010 11:40 PM
Antonio, what you are saying is that the code below will work properly on your Windows 7 ??
( The DLL in question is not important, because here the program hans up with other DLLs also)

Code (fw): Select all Collapse
hDLL := LoadLibrary("iSEDQuickPDF.dll")
IF hDLL < 33
    MsgInfo("Problem reading 'iSEDQuickPdf.dll'")
    RETURN NIL
ENDIF
[b]cFarProc := GetProcAddress(hDLL, "iSEDUnlockKey",.T.,LONG,       STRING)[/b]
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX""  // This is the UNLOCK key (not real of course)
<strong>r := CallDLL( cFarProc,cString)</strong>
IF r == 0
    FreeLib32( hDLL )
    MsgInfo("Cannot verify the PassKey !")
    RETURN NIL
ENDIF



On my Windows 7 Ultimate (32-bit) this kind of calling the DLL functions does not work...

On my Windows 7 The same function must be called this way to work:
Code (fw): Select all Collapse
cString := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"   
r := PDF_Connect( cString )

DLL Function PDF_Connect(wString AS  STRING)) AS LONG PASCAL FROM "iSEDUnlockKey" LIB "iSEDQuickPdf.dll"


Don't know what to say....
If the DLLs I am using are somehow special, I should have problems using either method to compile and run?
Using the 1st method it compiles and run on XP only
Using the 2nd method it compiles and run on XP and Windows 7 properly

I cannot understand why then I can compile and run normally on XP using method 1. but not on Windows 7 ?
This is why I have to revise all my PRGs which uses method 1. dll function calls
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: DLL functions usage in Win 7
Posted: Sun Jul 04, 2010 11:43 PM
Antonio Linares wrote:Boris,

Please notice that in recent FWH builds, we renamed CallDll() into FWCallDll() as Harbour implemented a function CallDll().

Please try to rename your CallDll() calls with FWCallDll(), thanks

The latest FWH I bought from you is version 8.11, is there a name change in this version also? ( from CallDll() to FWCallDll() )
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: DLL functions usage in Win 7
Posted: Mon Jul 05, 2010 12:18 AM

Boris,

Please notice that the function to use is GetProcAdd() (special implementation for FWH) and not GetProcAddress() (Windows API standard one).

Thats probably why DLL FUNCTION ... works fine for you, as it properly calls GetProcAdd() but your calls to Windows API CallDll() (your FWH version did not have a FWCallDll()) are crashing because they get a wrong value from GetProcAddress().

Resuming: You must call GetProcAdd() instead of GetProcAddress() :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: DLL functions usage in Win 7
Posted: Mon Jul 05, 2010 07:41 PM
Antonio Linares wrote:Boris,

Please notice that the function to use is GetProcAdd() (special implementation for FWH) and not GetProcAddress() (Windows API standard one).

Thats probably why DLL FUNCTION ... works fine for you, as it properly calls GetProcAdd() but your calls to Windows API CallDll() (your FWH version did not have a FWCallDll()) are crashing because they get a wrong value from GetProcAddress().

Resuming: You must call GetProcAdd() instead of GetProcAddress() :-)


Antonio,
this explanation looks logical.
But I cannot understand, why the code using GetProcAddress() -> CallDll() works perfecti for years on XP machine.
When I transfer the same project folder to Windows 7 and compile the program, when I run it, it hangs?

My fear is what is so different in Operating Systems not been able to run the same code, when COMPILED on different platform, using GetProcAddress() -> CallDll():
1. The code compiled on XP
- Runs on XP
- Runs on Windows 7

2. The code compiled on Windows 7
- Doesn't work on Windows 7
- Doesn't work on XP

Luckily enough there is solution to be able to compile and work on Windows 7 and XP, what I have to do is to use DLL FUNCTION approach.

I tested here all kind of combinations and my definite conclusion is:
The code compiled on Windows 7 using GetProcAddress() -> CallDll() combination of calls will NOT work neither on Windows 7 nor on XP
The code compiled on XP using GetProcAddress() -> CallDll() combination of calls WILL WORK on Windows 7 and on XP
The code compiled on Windows 7 OR on XP using DLL FUNCTION... will work on Windows 7 AND on XP

I am in the middle of eliminating GetProcAddress() -> CallDll() combination everywhere in my PRGs and replacing with the DLLFUNCTION... aproach, which will work on either platform.

Boris
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: DLL functions usage in Win 7
Posted: Tue Jul 06, 2010 02:40 AM
Boris,

Maybe you are using different Harbour versions on XP and on W7.

I am in the middle of eliminating GetProcAddress() -> CallDll() combination everywhere in my PRGs and replacing with the DLLFUNCTION... aproach, which will work on either platform.


Yes, thats the best way to go :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion