This MFC Project only a sample, you can redistribute all of this project.
void CSendCommandDlg::OnClickSendCommand()
{
LNSetThrowAllErrors(TRUE);
try {
if (! oSession.IsInitialized())
oSession.Init();
HANDLE hRetInfo;
STATUS nError;
char *pBuffer;
// Send Console Command to Server,
// Param 1 : Server Name
// Param 2 : Console Command
// Param 3 : Return String Memory Address
nError = NSFRemoteConsole ("APPDEV01/DEVELOPMENT", "tell amgr run \"UYGULAMALAR\\SalesForceAutomation.nsf\" 'Scheduled Agent 01'", &hRetInfo);
// Check any error
if (nError != NOERROR)
return;
/* Lock the returned buffer handle to obtain a pointer to the
text buffer containing the server command information */
pBuffer = OSLock (char, hRetInfo);
// Take Return message from buffer and show user,
MessageBox(LPCTSTR(pBuffer), "", MB_OK);
// Unlock Buffer
OSUnlock (hRetInfo);
// Free Memory Address
OSMemFree (hRetInfo);
return;
} catch (LNSTATUS error) {
char errorBuf[LNERROR_MESSAGE_LENGTH];
LNGetErrorMessage(error, errorBuf);
MessageBox ( errorBuf, "ERROR", MB_OK );
return;
}
}