Page 1 of 1

Interface Generator - How to use?!

Posted: Wed Aug 03, 2005 7:19 am
by kawawong
Hi,

I have used Interface Generator to generate the interface from a dll as follows.

Code: Select all

; Interface generated by Interface Generator 1.0, Date 08/02/2005 

; HbDAO, HB++ Data Access Objects

; Enumerations

Enumeration ; HB_DeleteMode
  #hbRecordDelete = 0
  #hbRecordArchive = 1
  #hbRecordRemove = 2
EndEnumeration

; DispInterfaces

Interface IHB_Recordset Extends IDispatch
  OpenTable(a,b)
  Close()
  AddNew()
  CancelUpdate()
  Delete(a)
  Edit()
  LookupUniqueID(a)
  MoveFirst()
  MoveLast()
  MoveNext()
  MovePrevious()
  Update()
  Blank()
  CreateTable(a,b,c,d,e)
  get_CreateOlePicture(a,b,c,d,e)
  get_CreateHBBitmap(a,b,c,d,e)
  get_AbsolutePosition(a)
  put_AbsolutePosition(a)
  get_BOF(a)
  get_EOF(a)
  get_RecordCount(a)
  get_AppInfoBlock(a)
  put_AppInfoBlock(a,b,c,d)
  get_SortInfoBlock(a)
  put_SortInfoBlock(a,b,c,d)
  get_FieldByIndex(a,b)
  put_FieldByIndex(a,b,c,d,e)
  get_FieldCount(a)
  get_FieldName(a,b)
  get_Field(a,b)
  put_Field(a,b,c,d,e)
EndInterface

Interface IHB_RawDB Extends IDispatch
  OpenTable(a)
  Close()
  AddNew()
  CancelUpdate()
  Delete(a)
  Edit()
  LookupUniqueID(a)
  MoveFirst()
  MoveLast()
  MoveNext()
  MovePrevious()
  Update()
  Blank()
  CreateTable(a,b,c,d)
  Truncate(a)
  get_AbsolutePosition(a)
  put_AbsolutePosition(a)
  get_BOF(a)
  get_EOF(a)
  get_RecordCount(a)
  get_AppInfoBlock(a)
  put_AppInfoBlock(a,b,c,d)
  get_SortInfoBlock(a)
  put_SortInfoBlock(a,b,c,d)
  get_RecordData(a)
  put_RecordData(a,b,c,d)
  get_Int8At(a,b)
  put_Int8At(a,b)
  get_UInt8At(a,b)
  put_UInt8At(a,b)
  get_Int16At(a,b)
  put_Int16At(a,b)
  get_UInt16At(a,b)
  put_UInt16At(a,b)
  get_Int32At(a,b)
  put_Int32At(a,b)
  get_UInt32At(a,b)
  put_UInt32At(a,b)
  get_DoubleAt(a,b)
  put_DoubleAt(a,b)
  get_SingleAt(a,b)
  put_SingleAt(a,b)
  get_DateAt(a,b)
  put_DateAt(a,b,c,d,e)
  get_BooleanAt(a,b)
  put_BooleanAt(a,b)
  get_StringAt(a,b)
  put_StringAt(a,b)
  get_FixedLengthStringAt(a,b,c)
  put_FixedLengthStringAt(a,b,c)
  get_UniqueID(a)
  put_UniqueID(a)
  get_Category(a)
  put_Category(a)
  get_Dirty(a)
  get_Secret(a)
  put_Secret(a)
EndInterface
Now, I want to use IHB_Recordset\OpenTable(a,b) , i.e.

Code: Select all

[VOffset($1C)] HRESULT OpenTable([in] BSTR PdbFile,
     [in] BSTR HbxFile)
and I try

Code: Select all

Global HbDao.IHB_Recordset
result.l = HbDao\OpenTable(PdbFile.s,HbxFile.s)
(PdbFile.s and HbxFile.s are the path and filename I want to pass into it)

and it generates error:

Code: Select all

Bad parameter type, number expected instead of string
Any idea?! :? Thanks a lot.

Posted: Wed Aug 03, 2005 8:06 am
by DarkDragon

Code: Select all

result.l = HbDao\OpenTable(@PdbFile.s,@HbxFile.s)

Posted: Wed Aug 03, 2005 8:10 am
by traumatic
DarkDragon wrote:

Code: Select all

result.l = HbDao\OpenTable(@PdbFile.s,@HbxFile.s)
Guess that won't work, BSTR is widechar so you'll need to convert
the string using MultiByteToWideChar() beforehand.

Posted: Wed Aug 03, 2005 10:26 am
by DarkDragon
traumatic wrote:
DarkDragon wrote:

Code: Select all

result.l = HbDao\OpenTable(@PdbFile.s,@HbxFile.s)
Guess that won't work, BSTR is widechar so you'll need to convert
the string using MultiByteToWideChar() beforehand.
Well, I just combined what's aviable for me:
Bad parameter type, number expected instead of string
And he wants to send a string to the function, so I've choosen that method.

Posted: Wed Aug 03, 2005 10:40 am
by traumatic
Yes but he wrote:

Code: Select all

[VOffset($1C)] HRESULT OpenTable([in] BSTR PdbFile,
     [in] BSTR HbxFile) 
;)

Posted: Thu Aug 04, 2005 2:52 am
by kawawong
Hi, thanks all.

I use the following function and there is no error now.

Code: Select all

Procedure BSTR(st$) 
   wst = WCHAR(st$) 
   bstr = SysAllocString_(wst) 
   FreeMemory(wst) 
   ProcedureReturn  bstr    
EndProcedure 
Still some problem, but your help is much useful to me. Thanks in advance.

:D