Click here to Skip to main content
15,039,714 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
Kushagra Tiwari21-Oct-09 3:39
MemberKushagra Tiwari21-Oct-09 3:39 
QuestionRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
David Crow21-Oct-09 3:52
MemberDavid Crow21-Oct-09 3:52 
AnswerRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
Kushagra Tiwari21-Oct-09 3:59
MemberKushagra Tiwari21-Oct-09 3:59 
QuestionRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
Kushagra Tiwari21-Oct-09 4:23
MemberKushagra Tiwari21-Oct-09 4:23 
AnswerRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
David Crow21-Oct-09 4:36
MemberDavid Crow21-Oct-09 4:36 
AnswerRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
Covean21-Oct-09 5:05
MemberCovean21-Oct-09 5:05 
AnswerRe: MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? Pin
Roger Stoltz21-Oct-09 5:43
MemberRoger Stoltz21-Oct-09 5:43 
QuestionJavaScript call from C++ Pin
cdpc20-Oct-09 20:37
Membercdpc20-Oct-09 20:37 
Here is a example showed how to pass the string parameter to the javaScript function.
http://www.codeproject.com/KB/COM/jscalls.aspx
but I want to pass a userdefined data type such as a struct.

this is my code but Invoke method failed (incorrect variable type). please help me,thanks.
//self defined data type:
	typedef  struct   
	{   
		CComBSTR s;   
		int		 n;
	}MyData;   


bool CWebPage::CallJScript(const CString strFunc,CComVariant* pVarResult)
{
	CComPtr<IDispatch> spScript;
	if(!GetJScript(spScript))
	{
		ShowError(_T("Cannot GetScript"));
		return false;
	}
	CComBSTR bstrMember(strFunc);
	DISPID dispid = NULL;
	HRESULT hr = spScript->GetIDsOfNames(IID_NULL,&bstrMember,1,
		LOCALE_SYSTEM_DEFAULT,&dispid);
	if(FAILED(hr))
	{
		ShowError(GetSystemErrorMessage(hr));
		return false;
	}


	DISPPARAMS dispparams;
	memset(&dispparams, 0, sizeof dispparams);
	dispparams.cArgs = 1;
	dispparams.rgvarg = new VARIANT[dispparams.cArgs];

	SAFEARRAY *psaData = NULL;	
	SAFEARRAYBOUND saBound = {1,0};

	MyData *pMyData = NULL;

	psaData = SafeArrayCreate(VT_VARIANT,1,&saBound);
	SafeArrayAccessData(psaData,reinterpret_cast<void **>(&pMyData));
	pMyData[0].s = SysAllocString(L"Steve");
	pMyData[0].n = 8;
	SafeArrayUnaccessData(psaData);

	dispparams.rgvarg[0].parray = psaData;
	dispparams.rgvarg[0].vt = VT_ARRAY;
	dispparams.cNamedArgs = 0;

	EXCEPINFO excepInfo;
	memset(&excepInfo, 0, sizeof excepInfo);
	CComVariant vaResult;
	UINT nArgErr = (UINT)-1;  // initialize to invalid arg

	hr = spScript->Invoke(dispid,IID_NULL,0,
		DISPATCH_METHOD,&dispparams,&vaResult,&excepInfo,&nArgErr);

	delete [] dispparams.rgvarg;
	if(FAILED(hr))
	{
		ShowError(GetSystemErrorMessage(hr));//errormsg "incorrect variable type"
		return false;
	}

	if(pVarResult)
	{
		*pVarResult = vaResult;
	}
	return true;
}

//javaScript code
<script type="text/javascript">
		var obj = {
		string: "sss",
		ints: 123
		}
			function showMessage(obj){
				alert(obj.string);
				alert(obj.ints);
			}
		</script>


I like c++

AnswerRe: JavaScript call from C++ Pin
CPallini20-Oct-09 22:01
mveCPallini20-Oct-09 22:01 
AnswerRe: JavaScript call from C++ Pin
Adam Roderick J20-Oct-09 22:38
MemberAdam Roderick J20-Oct-09 22:38 
Questionhow to stop a .exe? Pin
002comp20-Oct-09 20:24
Member002comp20-Oct-09 20:24 
QuestionRe: how to stop a .exe? Pin
CPallini20-Oct-09 20:27
mveCPallini20-Oct-09 20:27 
AnswerRe: how to stop a .exe? Pin
002comp20-Oct-09 20:39
Member002comp20-Oct-09 20:39 
QuestionRe: how to stop a .exe? Pin
CPallini20-Oct-09 20:46
mveCPallini20-Oct-09 20:46 
AnswerRe: how to stop a .exe? Pin
002comp20-Oct-09 21:18
Member002comp20-Oct-09 21:18 
GeneralRe: how to stop a .exe? Pin
Rajesh R Subramanian20-Oct-09 21:21
professionalRajesh R Subramanian20-Oct-09 21:21 
GeneralRe: how to stop a .exe? Pin
ThatsAlok20-Oct-09 21:52
MemberThatsAlok20-Oct-09 21:52 
GeneralRe: how to stop a .exe? Pin
CPallini21-Oct-09 0:26
mveCPallini21-Oct-09 0:26 
GeneralRe: how to stop a .exe? Pin
002comp21-Oct-09 0:28
Member002comp21-Oct-09 0:28 
GeneralRe: how to stop a .exe? Pin
Rajesh R Subramanian21-Oct-09 6:48
professionalRajesh R Subramanian21-Oct-09 6:48 
QuestionRe: how to stop a .exe? Pin
Randor 20-Oct-09 21:49
professional Randor 20-Oct-09 21:49 
AnswerRe: how to stop a .exe? Pin
ThatsAlok20-Oct-09 21:51
MemberThatsAlok20-Oct-09 21:51 
AnswerRe: how to stop a .exe? ADDENDUM Pin
ThatsAlok20-Oct-09 21:52
MemberThatsAlok20-Oct-09 21:52 
GeneralRe: how to stop a .exe? ADDENDUM Pin
Richard MacCutchan21-Oct-09 2:21
mveRichard MacCutchan21-Oct-09 2:21 
Questiondll for project Pin
MA Awan20-Oct-09 18:54
MemberMA Awan20-Oct-09 18:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.