From: Darmadi on
Hi to all,

I have an C Code to translate to VO

get_sessioninfo (handle_t handle, const char *format, char **info)


//NB: char **info

Please help me,

Thanks,
Darmadi
From: Mathias on
Hi Darmandi,

Why only this line? Sometimes it's better to translate the whole
routine so that you see the circumstances for each method call.

What I can do however is to help you with the data types.

local hHandle as ptr
local pSFormat,pSInfo as psz
local ppInfo as ptr

hHandle := // I suppose you get the handle from somewhere
pSFormat := String2Psz(sFormat) // Make a c-string from a VO string
pSInfo := String2Psz(sInfo) // Make a c-string from a VO string
ppInfo := @pSInfo // Get the adress for the pointer to the c-string

get_sessioninfo(hHandle,pSformat,ppInfo)

String2Psz allocates a c-string buffer in memory and copies the string
contents to it. This buffer is released automatically when this method/
function/procedure has ended. If you want the buffer to live longer
(if the recieving module needs it longer and not just for this single
call) you can allocate it with StringAlloc(sString) and Release it
with MemFree(pString).

Hope this helps...

Mathias

On 5 Nov, 04:12, "Darmadi" <supp...(a)gfsoftindo.com> wrote:
> Hi to all,
>
> I have an C Code to translate to VO
>
> get_sessioninfo (handle_t handle, const char *format, char **info)
>
> //NB: char **info
>
> Please help me,
>
> Thanks,
> Darmadi

From: Darmadi on
Hi Mathias,

This the sample from C :

char *info = 0;

status = hasp_get_sessioninfo(handle, HASP_UPDATEINFO, &info);

/* check if operation was successful */
if (status != HASP_STATUS_OK)
{
switch (status)
{
case HASP_FEATURE_NOT_FOUND:
break;
case HASP_INV_HND:
break;
case HASP_INV_FORMAT:
break;
default:
break;
}
}

/* use the information */

hasp_free(info);



I have problem with this code:

char *info = 0;

and

parameter " &info "


what I do in VO:

_DLL FUNC HASP_Get_Sessioninfo( handle AS DWORD, format AS PSZ, info AS
PTR ) AS DWORD PASCAL:Cavohasp.hasp_get_sessioninfo


Really thanks a lot for your help,
Regards,
Darmadi

From: Mathias on
Hi Again Darmadi

I suppose that HASP_UPDATEINFO is a string constant. In that case you
can define it in VO (define HASP_UPDATEINFO := "whatever")

The VO code would then be

local hHandle as ptr
local pSInfo as psz
local dwStatus as dword

hHandle := // I suppose you get the handle from somewhere

pSinfo := NULL_PSZ // char *info = 0;

// As HASP_UPDATEINFO is a constant it will not be moved in memory.
This makes it possible to use a simple type conversion for the second
parameter. Note that this is not safe for strings in dynamic memory
(string variables).

dwStatus = hasp_get_sessioninfo(hHandle,psz(HASP_UPDATEINFO), @pSInfo)

do case
case HASP_FEATURE_NOT_FOUND
// Infobox or?
case HASP_INV_HND
// Infobox or?
case HASP_INV_FORMAT
// Infobox or?
endcase

hasp_free(pSInfo)

Mathias

On 5 Nov, 08:12, "Darmadi" <supp...(a)gfsoftindo.com> wrote:
> Hi Mathias,
>
> This the sample from C :
>
> char *info = 0;
>
> status = hasp_get_sessioninfo(handle, HASP_UPDATEINFO, &info);
>
> /* check if operation was successful */
> if (status != HASP_STATUS_OK)
> {
>     switch (status)
>     {
>         case HASP_FEATURE_NOT_FOUND:
>             break;
>         case HASP_INV_HND:
>             break;
>         case HASP_INV_FORMAT:
>             break;
>         default:
>             break;
>     }
>
> }
>
> /* use the information */
>
> hasp_free(info);
>
> I have problem with this code:
>
> char *info = 0;
>
> and
>
> parameter " &info "
>
> what I do in VO:
>
> _DLL FUNC HASP_Get_Sessioninfo( handle AS DWORD, format AS PSZ, info AS
> PTR ) AS DWORD PASCAL:Cavohasp.hasp_get_sessioninfo
>
> Really thanks a lot for your help,
> Regards,
> Darmadi

From: Darmadi on
Hi again Mathias,

I have modified my code:

ptrVendor := PTR( _CAST, String2Psz( HASP_VENDOR_CODE ) )

dwStatus := HASP_Login( 0 + HASP_PROGNUM_FEATURETYPE, ptrVendor,
@dwHASPHandle )

IF dwStatus == HASP_STATUS_OK

pszString := NULL_PSZ

dwStatus := HASP_Get_Sessioninfo( dwHASPHandle,
String2Psz(HASP_KEYINFO), @pszString )

IF dwStatus == HASP_STATUS_OK

cString := Psz2String(pszString)
ErrorBox{SELF,cString}:Show()

ELSE
ErrorBox{SELF,"FAILED!!!"}:Show()
ENDI

hasp_free(pszString)

ENDI

// RESULT : Showing a ErrorBox, "FAILED !!!"


the C header:
#define HASP_UPDATEINFO "<haspformat format=\"updateinfo\"/>" /*!<
hasp_get_sessioninfo() format to get update info (C2V) */
#define HASP_SESSIONINFO "<haspformat format=\"sessioninfo\"/>" /*!<
hasp_get_sessioninfo() format to get session info */
#define HASP_KEYINFO "<haspformat format=\"keyinfo\"/>" /*!<
hasp_get_sessioninfo() format to get key/hardware info */

my constant:
DEFINE HASP_UPDATEINFO := '<haspformat format=\"updateinfo\"/>' /*!<
hasp_get_sessioninfo() format to get update info (C2V) */
DEFINE HASP_SESSIONINFO := '<haspformat format=\"sessioninfo\"/>' /*!<
hasp_get_sessioninfo() format to get session info */
DEFINE HASP_KEYINFO := '<haspformat format=\"keyinfo\"/>' /*!<
hasp_get_sessioninfo() format to get key/hardware info */


I have done as you said, but still could not success call that function.
Is there something I miss?

Thanks.
Regards,
Darmadi

 |  Next  |  Last
Pages: 1 2
Prev: Graphics4VO to vulcan
Next: Language settings problems