gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Visual C++ Mygnokii GUI Problem


From: Alan Smith
Subject: Visual C++ Mygnokii GUI Problem
Date: Wed, 24 Apr 2002 03:38:31 -0700 (PDT)

Hello,

I am trying to create a Visual C++ GUI using mygnokii
commands.  I have so far gotten some commands working
but I am having problems with --sendsms.

This I know is more a programming question but perhaps
there is someone who has experienced something
similar.

Thanks for any help.

Here is the Problem:

/********************************************/

I am having a problem when sending the command line
argument while using CreateProcess(). (Both commands
run fine on a dos prompt).

When I send the following command it works fine:
sprintf (cmdline, "C:\\THE
PROJECT\\Interface\\mygnokii --identify");

But when I send this line I'm told that the "Process
cannot be created":
sprintf (cmdline, "C:\\THE PROJECT\\Interface\\echo
Test Message | mygnokii --sendsms ********");

Here is the code.

/***************************************************/
#include 
#include "resource.h"
...

void CNewSMSDlg::OnNewSMSSendbtn() 
{
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);

SECURITY_ATTRIBUTES sat;
PROCESS_INFORMATION pinfo;
STARTUPINFO startinfo;
HANDLE hReadPipe, hWritePipe;

char cmdline[300];
char buffer[1024];
HRESULT res;
DWORD bytesread;

sprintf (cmdline, "C:\\THE PROJECT\\Interface\\echo
testing | mygnokii --sendsms ********");

// sprintf (cmdline, "C:\\THE
PROJECT\\Interface\\mygnokii --identify");


sat.nLength = sizeof(SECURITY_ATTRIBUTES);
sat.lpSecurityDescriptor = NULL;
sat.bInheritHandle = TRUE;

res = CreatePipe(&hReadPipe, &hWritePipe, &sat, NULL);
if(res==NULL)
{
MessageBox("CreatePipeFailed", "Error", MB_OK |
MB_ICONSTOP);
}

startinfo.cb = sizeof(STARTUPINFO);
GetStartupInfo(&startinfo);
startinfo.hStdError = hWritePipe; //here's where we
reroute stderr
startinfo.hStdOutput = hWritePipe; //and stdout to our
pipe
startinfo.dwFlags = STARTF_USESTDHANDLES |
STARTF_USESHOWWINDOW;
startinfo.wShowWindow = SW_HIDE; //This hides the
console window


res = CreateProcess(NULL, cmdline, NULL, NULL, TRUE,
NULL, NULL, NULL, &startinfo, &pinfo);
if(res==NULL)
{
MessageBox("CreateProcess Failed", "Error", MB_OK |
MB_ICONSTOP);
}
CloseHandle(hWritePipe); 

SendDlgItemMessage(IDC_NEWSMS_EDITBOX, WM_SETTEXT, 0,
0); //clear the field


//read from the pipe using the read handle
res = ReadFile(hReadPipe, buffer, 1023, &bytesread,
NULL);
if(res==NULL)
{
MessageBox("CreateRead Failed", "Error", MB_OK |
MB_ICONSTOP);
exit(1);
}

else
{
SendDlgItemMessage(IDC_NEWSMS_EDITBOX, EM_SETSEL, -1,
0);
SendDlgItemMessage(IDC_NEWSMS_EDITBOX, EM_REPLACESEL,
FALSE, (LPARAM)buffer);
}

CloseHandle(hReadPipe);
} 









 

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]