المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Error compiling call to Windows API function.



C++ Programming
03-31-2009, 05:11 PM
Hi

I am working on a CPP that created services.

It complains about the last value in the SERVICE_FAILURE_ACTIONS struct.

According to the Microsoft it is defined as follows:


lpsaActions

A pointer to an array of SC_ACTION structures.


--------------------
When compiling code that calls the function that sets the failure acitons of a server I get the following output.



---------------------------------------------------------------


SC_ACTION *action_array[1];


SC_ACTION* action_str = new SC_ACTION();
action_str->Type = SC_ACTION_RESTART;
action_str->Delay =6000;

action_array[0] = action_str;



SERVICE_FAILURE_ACTIONS actions_struct;
actions_struct.dwResetPeriod = 86400;
actions_struct.lpRebootMsg = NULL;
actions_struct.lpCommand = NULL;
actions_struct.cActions = 1;
LINE(588)---> actions_struct.lpsaActions = action_array;

int result2 = ChangeServiceConfig2W(
service,
SERVICE_CONFIG_FAILURE_ACTIONS,
&actions_struct);

------------------------
OUTPUT

#
Building post_service.dll ...
#
cl.exe @C:\xxxx\nma05692.
#
WindowsService.cpp
#
c:\xxxxxxx\windowsservice.cpp(588) :
#
error C2440: '=' : cannot convert from 'struct _SC_ACTION *[1]' to 'struct _SC_A
#
TION *'
#
Types pointed to are unrelated; conversion requires reinterpret_cast, C
#
style cast or function-style cast
#
NMAKE : U1077: 'cl.exe' : return code '0x2'
#
Stop.
---------------------------------------------


Is there something obvious that I am doing wrong here? My CPP is a little rusty. http://www.barakasoft.com/script/Forums/Images/smiley_frown.gif Would appreciate any help I can get