This is Unofficial EPICS BASE Doxygen Site
osdProcess.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include "osiProcess.h"
+ Include dependency graph for osdProcess.c:

Go to the source code of this file.

Macros

#define STRICT
 

Functions

LIBCOM_API osiGetUserNameReturn epicsStdCall osiGetUserName (char *pBuf, unsigned bufSizeIn)
 
LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess (const char *pProcessName, const char *pBaseExecutableName)
 

Macro Definition Documentation

#define STRICT

Definition at line 24 of file osdProcess.c.

Function Documentation

LIBCOM_API osiGetUserNameReturn epicsStdCall osiGetUserName ( char *  pBuf,
unsigned  bufSizeIn 
)

Definition at line 29 of file osdProcess.c.

30 {
31  DWORD bufsize;
32 
33  if ( bufSizeIn > 0xffffffff ) {
34  return osiGetUserNameFail;
35  }
36 
37  bufsize = (DWORD) bufSizeIn;
38 
39  if ( ! GetUserName (pBuf, &bufsize) ) {
40  return osiGetUserNameFail;
41  }
42 
43  if ( *pBuf == '\0' ) {
44  return osiGetUserNameFail;
45  }
46 
47  return osiGetUserNameSuccess;
48 }
LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess ( const char *  pProcessName,
const char *  pBaseExecutableName 
)

Definition at line 51 of file osdProcess.c.

52 {
53  BOOL status;
54  STARTUPINFO startupInfo;
55  PROCESS_INFORMATION processInfo;
56 
57  GetStartupInfo ( &startupInfo );
58  startupInfo.lpReserved = NULL;
59  startupInfo.lpTitle = (char *) pProcessName;
60  startupInfo.dwFlags = STARTF_USESHOWWINDOW;
61  startupInfo.wShowWindow = SW_SHOWMINNOACTIVE;
62 
63  status = CreateProcess (
64  NULL, /* pointer to name of executable module (not required if command line is specified) */
65  (char *) pBaseExecutableName, /* pointer to command line string */
66  NULL, /* pointer to process security attributes */
67  NULL, /* pointer to thread security attributes */
68  FALSE, /* handle inheritance flag */
69  CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS, /* creation flags */
70  NULL, /* pointer to new environment block (defaults to caller's environement) */
71  NULL, /* pointer to current directory name (defaults to caller's current directory) */
72  &startupInfo, /* pointer to STARTUPINFO */
73  &processInfo /* pointer to PROCESS_INFORMATION */
74  );
75  if ( status == 0 ) {
76  DWORD W32status;
77  LPVOID errStrMsgBuf;
78  LPVOID complteMsgBuf;
79 
80  W32status = FormatMessage (
81  FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
82  NULL,
83  GetLastError (),
84  MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
85  (LPTSTR) &errStrMsgBuf,
86  0,
87  NULL
88  );
89 
90  if ( W32status ) {
91  char *pFmtArgs[6];
92  pFmtArgs[0] = "Failed to start executable -";
93  pFmtArgs[1] = (char *) pBaseExecutableName;
94  pFmtArgs[2] = errStrMsgBuf;
95  pFmtArgs[3] = "Changes may be required in your \"path\" environment variable.";
96 
97  W32status = FormatMessage(
98  FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING |
99  FORMAT_MESSAGE_ARGUMENT_ARRAY | 80,
100  "%1 \"%2\". %3 %4",
101  0,
102  MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
103  (LPTSTR) &complteMsgBuf,
104  0,
105  pFmtArgs
106  );
107  if (W32status) {
108  fprintf (stderr, "%s\n", (char *) complteMsgBuf);
109  LocalFree (complteMsgBuf);
110  }
111  else {
112  fprintf (stderr, "%s\n", (char *) errStrMsgBuf);
113  }
114 
115  /* Free the buffer. */
116  LocalFree (errStrMsgBuf);
117  }
118  else {
119  fprintf (stderr, "!!WARNING!!\n");
120  fprintf (stderr, "Unable to locate executable \"%s\".\n", pBaseExecutableName);
121  fprintf (stderr, "You may need to modify your \"path\" environment variable.\n");
122  }
124  }
125 
127 }
#define FALSE
Definition: dbDefs.h:32
pvd::Status status
#define NULL
Definition: catime.c:38
#define stderr
Definition: epicsStdio.h:32