Write C code and return 0 not work.

Write C code and return 0 not work.

Postby richard-service » Mon Dec 11, 2023 3:16 am

Dear Antonio, Mr.Rao

Why I run INITMODULE function return 0, but correct is some number not 0

I have a dll file.

C code
Code: Select all  Expand view

unsigned long InitModule ( char* pszModuleName, ;
                           void* pInitArgs,     ;
                           unsigned long* pulModuleHandle);
 


FWH code
Code: Select all  Expand view

INITMODULE("HCAPKCS11",@hICModule)

#pragma BEGINDUMP

   #include "windows.h"
   #include "hbapi.h"

   int WINAPI InitModule( LPSTR pszModuleName, void * pInitargs, LPDWORD pulModuleHandle);
                                       
   HB_FUNC( INITMODULE)
   {
     LPSTR   pszModuleName   = (char *) hb_parc(1);
     LPDWORD   pulModuleHandle = hb_parnl(2);
     LONG err;
     err=InitModule( pszModuleName, NULL, &pulModuleHandle );
     hb_retnl(err);
   }
#pragma ENDDUMP
 
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 764
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Write C code and return 0 not work.

Postby cnavarro » Mon Dec 11, 2023 5:48 am

richard-service wrote:Dear Antonio, Mr.Rao

Why I run INITMODULE function return 0, but correct is some number not 0

I have a dll file.

C code
Code: Select all  Expand view

unsigned long InitModule ( char* pszModuleName, ;
                           void* pInitArgs,     ;
                           unsigned long* pulModuleHandle);
 


FWH code
Code: Select all  Expand view

INITMODULE("HCAPKCS11",@hICModule)

#pragma BEGINDUMP

   #include "windows.h"
   #include "hbapi.h"

   int WINAPI InitModule( LPSTR pszModuleName, void * pInitargs, LPDWORD pulModuleHandle);
                                       
   HB_FUNC( INITMODULE)
   {
     LPSTR   pszModuleName   = (char *) hb_parc(1);
     LPDWORD   pulModuleHandle = hb_parnl(2);
     LONG err;
     err=InitModule( pszModuleName, NULL, &pulModuleHandle );
     hb_retnl(err);
   }
#pragma ENDDUMP
 


Please, try
Code: Select all  Expand view

INITMODULE("HCAPKCS11", , @hICModule)

#pragma BEGINDUMP

   #include "windows.h"
   #include "hbapi.h"

   int WINAPI InitModule( LPSTR pszModuleName, void * pInitargs, LPDWORD pulModuleHandle);
                                       
   HB_FUNC( INITMODULE)
   {
     LPSTR   pszModuleName   = (char *) hb_parc(1);
     LPDWORD   pulModuleHandle = hb_parnl(3);
     LONG err;
     err=InitModule( pszModuleName, NULL, &pulModuleHandle );
     hb_retnl(err);
   }
#pragma ENDDUMP
 
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: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Write C code and return 0 not work.

Postby richard-service » Thu Dec 14, 2023 10:49 am

cnavarro wrote:
richard-service wrote:Dear Antonio, Mr.Rao

Why I run INITMODULE function return 0, but correct is some number not 0

I have a dll file.

C code
Code: Select all  Expand view

unsigned long InitModule ( char* pszModuleName, ;
                           void* pInitArgs,     ;
                           unsigned long* pulModuleHandle);
 


FWH code
Code: Select all  Expand view

INITMODULE("HCAPKCS11",@hICModule)

#pragma BEGINDUMP

   #include "windows.h"
   #include "hbapi.h"

   int WINAPI InitModule( LPSTR pszModuleName, void * pInitargs, LPDWORD pulModuleHandle);
                                       
   HB_FUNC( INITMODULE)
   {
     LPSTR   pszModuleName   = (char *) hb_parc(1);
     LPDWORD   pulModuleHandle = hb_parnl(2);
     LONG err;
     err=InitModule( pszModuleName, NULL, &pulModuleHandle );
     hb_retnl(err);
   }
#pragma ENDDUMP
 


Please, try
Code: Select all  Expand view

INITMODULE("HCAPKCS11", , @hICModule)

#pragma BEGINDUMP

   #include "windows.h"
   #include "hbapi.h"

   int WINAPI InitModule( LPSTR pszModuleName, void * pInitargs, LPDWORD pulModuleHandle);
                                       
   HB_FUNC( INITMODULE)
   {
     LPSTR   pszModuleName   = (char *) hb_parc(1);
     LPDWORD   pulModuleHandle = hb_parnl(3);
     LONG err;
     err=InitModule( pszModuleName, NULL, &pulModuleHandle );
     hb_retnl(err);
   }
#pragma ENDDUMP
 


Thanks a lot. it's work.
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 764
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Write C code and return 0 not work.

Postby richard-service » Thu Dec 14, 2023 10:54 am

Dear all

This's other function below:

Code: Select all  Expand view

nsigned long GetKeyObjectHandle (
  unsigned long ulModuleHandle,
  unsigned long ulSessionHandle,
  int iKeyType,
  unsigned char* pKeyID,
  int iKeyIDLength,
  void* pvPara,
  int iParaLength,
  unsigned long* pulKeyObjectHandle)
 


How to make HB_GetKeyObjectHandle() function?

void* pvPara => Deadly

This is VB call function below:
Code: Select all  Expand view

Dim hKeyObject As Long
sKeyID(0) = &H1    
iKeyType = 0    
rtn = GetKeyObjectHandle(hICModule, hICSession, iKeyType, 0, 0, VarPtr(sKeyID(0)), 1, VarPtr(hKeyObject))
 
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 764
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests