Link to home
Start Free TrialLog in
Avatar of qbawler311
qbawler311

asked on

Need help initializing a variable of type LPWSTR?

I am currently getting the following error when I try to initialize a member of the AT_INFO structure:

C:\rocklobsterj\Ptest1\Netschedule.cpp(25) : error C2440: '=' : cannot convert from 'char [42]' to 'unsigned short *'

The NetScheduleJobAdd() function takes three parameters, one of which uses an AT_INFO structure.  One of its members is of type LPWSTR.  


typedef struct _AT_INFO {
    DWORD   JobTime;
    DWORD   DaysOfMonth;
    UCHAR   DaysOfWeek;
    UCHAR   Flags;
    LPWSTR  Command;
} AT_INFO, *PAT_INFO, *LPAT_INFO;
 
Here's the way I'm attemting to initialize the 'Command' member:

AT_INFO myATINFO;
  myATINFO.JobTime = 36000000 ;
  myATINFO.DaysOfMonth = 0;
  myATINFO.DaysOfWeek = 1;        
  myATINFO.Flags = JOB_RUN_PERIODICALLY;
  myATINFO.Command = "c:\\rocklobsterj\\version1\\classes\\RLCITEST";  

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, if you have to deal with non-constant strings, you'll have to supply a conversion:

char acCommand [ MAX_PATH] = "c:\\rocklobsterj\\version1\\classes\\RLCITEST";
wchar_t awcCommand;

wsprintfW ( awcCommand, "%S", acCommand);

myATINFO.Command = awcCommand;
Avatar of qbawler311
qbawler311

ASKER

Thanks jkr, sorry so late.