Pointer to BYTE

This is a discussion on Pointer to BYTE within the C Programming forums, part of the General Programming Boards category; Hi, I am making the following Library function call in a C program: LibQueryActiveUsers( pSession, ulMaxUsers, bFormatted, bComplete, pusBadOrderCode, plSQLCode, ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    2

    Question Pointer to BYTE

    Hi,

    I am making the following Library function call in a C program:


    LibQueryActiveUsers( pSession, ulMaxUsers, bFormatted, bComplete,
    pusBadOrderCode, plSQLCode, pusNumRows, pbRows)

    The data is returned in pbRows and pbRows is defined as:

    pbRows
    BYTE * input
    The pointer to the row data. A query can return data in a variety of
    layouts, so pbRows is typed as a pointer to BYTE data. However, if the
    application has information about the layout of the data, it is possible to
    type this variable as a pointer to ROWTYPE data, where ROWTYPE is the
    name of a structure that is defined to match the returned row data.

    In my program, the call is made as follows:

    sreturn = LibQueryActiveUsers((SESSION_P *) hsession,
    ulMaxUsers,
    IS_TRUE,
    (BOOL) TRUE,
    &usBadOrderCode,
    &lSQLCode,
    &usNumRows,
    (unsigned char **) &stActiveUserRow
    );
    LIBFACTIVEUSERROW stActiveUserRow; //Declaration.

    How do I retrieve (print) data from pbRows?

    Thank you in advance.

  2. #2
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719
    Are you asking if you can use a separate structure which will work with the function? You can use void * or, for example:

    myfunction(SOMEFUNC *Blah);

    SOMEOTHERFUNC Bleh;

    myfunction((SOMEFUNC *)&Bleh);

    If you use other structures you have to make sure that they are still compatible while you convert them. As to the use of any-other structure I guess you could pass an arguement which denotes which structure/data types you are using. Does this answer your question?
    "What are you after - the vague post of the week award?" - Salem
    IPv6 Ready.
    Travel the world, meet interesting people...kill them.
    Trying to fix or change something, only guaruntees and perpetuates its existence.
    I don't know about angels, but it is fear that gives men wings.
    The problem with wanting something is the fear of losing it, or never having it. The thought makes you weak.

    E-Mail Xei

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    2
    The rows from the database call are in the LIBFACTIVEUSERROW (stActiveUserRow) structure that is described as :

    typedef struct
    {
    CHAR achUserName;
    CHAR achWorkstationID;
    SMALLINTSTR achLogonCount;
    } LIBFACTIVEUSERROW;

    In my PRINTfF statement, I do get some information back but it appears to be gibberish. I am not sure if I am getting back the address or data.

    for ( i = 0; i < usNumRows; i++ )

    printf("User Name = %s\n\n", stActiveUserRow.achUserName);
    //printf("User Name = %s\n\n", &RType.achUserName);
    printf("User Name = %u\n\n", stActiveUserRow.achUserName);
    printf("WorkStation Name = %s \n\n", stActiveUserRow.achWorkstationID);
    printf("WorkStation Name = %u \n\n", stActiveUserRow.achWorkstationID);
    printf("Logon Count = %s\n\n", stActiveUserRow.achLogonCount);
    printf("Logon Count = %u\n\n", stActiveUserRow.achLogonCount);

    My results are as follows:
    User Name = @U╡

    User Name = @U╡

    User Name = @U╡

    User Name = @U╡

    User Name = @U╡

    User Name = 1244940

    WorkStation Name = ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠♣

    WorkStation Name = 1244967

    Logon Count = ╠╠╠╠╠╠╠♣

    Logon Count = 1244985

    Press any key to continue

    So do I need a function to convert the data to a readable form or is there any other way.
    I hope I have not confused you.
    Last edited by kshah82; 05-06-2003 at 08:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why does C need pointer conversion
    By password636 in forum C Programming
    Replies: 2
    Last Post: 04-10-2009, 07:33 AM
  2. scope of a pointer?
    By Syneris in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2005, 08:40 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 01:19 AM
  5. Pointer to struct members
    By kybert in forum C Programming
    Replies: 7
    Last Post: 07-01-2003, 08:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21