Announcement

Collapse
No announcement yet.

How to convert this from C to PB long deviceData[MAXDEVICES];

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to convert this from C to PB long deviceData[MAXDEVICES];

    Trying to convert some C code.

    How to convert ths to PB from C long deviceData[MAXDEVICES];

    Code:
    void FindAndStart(HWND hDialog)
    {
    DWORD result;
        long  deviceData[MAXDEVICES];    
        long  hnd;
        long  count;
        int pid;
    
        result = EnumeratePIE(0x5F3, deviceData, count);
    
    }
    Is that an array???

  • #2
    Originally posted by David Clarke View Post
    Trying to convert some C code.

    How to convert ths to PB from C long deviceData[MAXDEVICES];

    Code:
    void FindAndStart(HWND hDialog)
    {
    DWORD result;
    long deviceData[MAXDEVICES];
    long hnd;
    long count;
    int pid;
    
    result = EnumeratePIE(0x5F3, deviceData, count);
    
    }
    Is that an array???
    Yes. An array of type LONG with a fixed size.
    At least, that is how I remember it.
    https://www.tutorialspoint.com/cprog...g/c_arrays.htm
    An array in C, initialized to 10 will be ten elements, 0 - 9.
    An array in PB, intialized to 10 will be eleven elements, 0 - 10.
    Code:
        LOCAL deviceData()
        REDIM deviceData(MAXDEVICES)
    The world is strange and wonderful.*
    I reserve the right to be horrifically wrong.
    Please maintain a safe following distance.
    *wonderful sold separately.

    Comment


    • #3
      I think you will find it is a long pointer to an array of longs.

      So possibly:

      Dim DevData(MaxDevices -1) as Long
      devicedata = varptr(DevData(0))

      More info about EnumeratePIE parameters here:

      https://www.autoitscript.com/forum/t...integer-array/

      Comment


      • #4
        Originally posted by Stuart McLachlan View Post
        I think you will find it is a long pointer to an array of longs.

        So possibly:

        Dim DevData(MaxDevices -1) as Long
        devicedata = varptr(DevData(0))

        More info about EnumeratePIE parameters here:

        https://www.autoitscript.com/forum/t...integer-array/
        Or:
        Code:
            LOCAL DevData as LONG PTR, StrBuffer as STRINGZ * (MAXDEVICES * 4)
            DevData = VARPTR(StrBuffer)
        The world is strange and wonderful.*
        I reserve the right to be horrifically wrong.
        Please maintain a safe following distance.
        *wonderful sold separately.

        Comment

        Working...
        X