Results 1 to 4 of 4

Thread: data types in structures

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    In a function I call I use the structure SYSTEM_POWER_STATUS. Under that stucture each different piece of information has a different data type. When I go to call it once it recieved the data it says im trying to pass a byte to argument two of MessageBox which lacks a cast. Here is a example. ACLineStatus is a byte in the structure.

    Code:
    int getsysdata()
    {
    SYSTEM_POWER_STATUS sysdata;
    
    GetSystemPowerStatus(&sysdata);
    
    MessageBox(NULL,sysdata.ACLineStatus, "System Data", MB_OK);
    
    return 0;
    }
    thanks for your help
    Matt

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    The MessageBox function is expecting a string. You need to make a string using the itoa() function or something similar, and pass that instead.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Guest
    Code:
    char buf[20];
    char* szText = itoa(sysdata.ACLineStatus, buf, 20);
    MessageBox(NULL, szText, "System Data", MB_OK);

  4. #4

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    thanks guys
    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width