Solved

Need help deciphering the parameters for the function 'NetScheduleJobAdd()'

Posted on 2001-06-14
5
346 Views
Last Modified: 2008-01-16
Greetings:

The second parameter for NetScheduleJobAdd() is a structure of type 'AT_INFO' which is defined as:

typedef struct _AT_INFO {
    DWORD   JobTime;
    DWORD   DaysOfMonth;
    UCHAR   DaysOfWeek;
    UCHAR   Flags;
    LPWSTR  Command;
} AT_INFO, *PAT_INFO, *LPAT_INFO;

My question is, what is necessary to initialize this structure before it is used in the NetScheduleJobAdd function?  This structure is contained in the second parameter below:

NetScheduleJobAdd( LPWSTR Servername,  LPBYTE Buffer,   LPDWORD JobId);
 
 
0
Comment
Question by:John500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 6190825
Remarks
Following are examples of how to schedule jobs using different properties supported by the NetScheduleJobAdd function.

To schedule a job that executes once

Set the DaysOfMonth member of the AT_INFO structure to zero.
Set the DaysOfWeek member to zero.
Set the JobTime member to the time the job should execute.
The job executes at the time specified by the JobTime member. After the job executes, it is deleted.

To schedule and delete a job that executes multiple times

Set the appropriate bits in the DaysOfMonth member of the AT_INFO structure.
Set the appropriate bits in the DaysOfWeek member. (You do not need to set both the DaysOfMonth and the DaysOfWeek members.)
Set the JobTime member to the time the job should execute.
The job executes at the time specified by the JobTime member, once for each day set in DaysOfMonth and DaysOfWeek. After each execution, the corresponding bit is cleared. When the last bit is cleared, the job is deleted.

To schedule a job that executes periodically

Set the appropriate bits in the DaysOfMonth member of the AT_INFO structure.
Set the appropriate bits in the DaysOfWeek member. (You do not need to set both the DaysOfMonth and the DaysOfWeek members.)
Set the JobTime member to the time the job should execute.
Set the job submission flag JOB_RUN_PERIODICALLY in the Flags member.
The job will execute periodically, at the time specified by the JobTime member, on each day set in DaysOfMonth and DaysOfWeek. The job will not be deleted as a result of the repeated executions. The only way to delete the job is by an explicit call to the NetScheduleJobDel function.

See AT_INFO for a description of the DaysOfWeek, DaysOfMonth, and job property bitmasks.

0
 

Author Comment

by:John500
ID: 6190991
proskig,

Thanks for the response.  I have MSDN and have read it a number of times regarding this function.  However, I still don't understand how to 'set' all of the things you mention.

In other words, it would be helpful to see code which shows the 'AT_INFO' structure actually being set.  Do you get my point?
0
 
LVL 3

Accepted Solution

by:
gmleeman earned 50 total points
ID: 6191394
Hi There

Use your code as is:

typedef struct _AT_INFO {
   DWORD   JobTime;
   DWORD   DaysOfMonth;
   UCHAR   DaysOfWeek;
   UCHAR   Flags;
   LPWSTR  Command;
} AT_INFO, *PAT_INFO, *LPAT_INFO;


Then in your code:

int main(void)
{
   char ascOther[80];
   AT_INFO myATINFO;

   myATINFO.DaysOfMonth = 0;
   myATINFO.DayOfWeek = 0;

   function(&myATINFO);

}

The above shows how to initialise two elements of the stucture, and to pass the variable as a pointer to a function.

The type AT_INFO can be treated now as "int" or "char".
(The *PAT_INFO, *LPAT_INFO could be a bit confusing...)



Hope this helps
0
 
LVL 30

Expert Comment

by:Axter
ID: 6191420
Hi gmleeman,
All of the experts here, for the most part have learn from other experts as to the proper etiquette
for posting answer.
 An answer should not be posted as an answer, if other experts have previously posted possible answers
as comments, and/or have already made contributions to the question.

There are many experts who never post answers as answer.  Instead, they post their answers as comments.
If you read the following link, you?ll see why this is the preferred method for many of our valued experts,
including myself.

http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp


Hi John500,
Feel free to click the [Reject Answer] button near (Answer-poster's) response, even if it seems like
a good answer.
Doing so will increase your chance of obtaining additional input from other experts.  Later, you can
click the [Select Comment as Answer] button on any response.
0
 

Author Comment

by:John500
ID: 6191472
gmleeman,

Thanks, that's definately the answer.  I should have thought of that!!

I can post another question if you like, otherwise, do you happen to know whether this function would run for, say, 2 days by vurtue of how the 'members' are set.

In other words if the main() looks like this:

main()
{

{
  char ascOther[80];
  AT_INFO myATINFO;

  myATINFO.DaysOfMonth = 2;
  myATINFO.DayOfWeek = 1;
  myATINFO.Flag = JOB_RUN_PERIODICALLY;

  NetScheduleJobAdd(server, buffer, JobId)


 return;
}

 ... regardless of whether the members are set correctly, I just want to know whether this program is capable of running for 2 days before quitting?

Thanks
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question