示例#1
0
HRESULT __stdcall CoCOMServer::ahkassign(/*in*/VARIANT name, /*in*/VARIANT value,/*out*/int* success)
{
   USES_CONVERSION;
	 if (success==NULL)
      return ERROR_INVALID_PARAMETER;
   TCHAR namebuf[MAX_INTEGER_SIZE];
   Var *var;
   if (   !(var = g_script.FindOrAddVar(name.vt == VT_BSTR ? OLE2T(name.bstrVal) : Variant2T(name,namebuf)))   )
      return ERROR_INVALID_PARAMETER;  // Realistically should never happen.
   AssignVariant(*var, value, false);
	return S_OK;
}
示例#2
0
VARIANT ahkFunctionVariant(LPTSTR func, VARIANT param1,/*[in,optional]*/ VARIANT param2,/*[in,optional]*/ VARIANT param3,/*[in,optional]*/ VARIANT param4,/*[in,optional]*/ VARIANT param5,/*[in,optional]*/ VARIANT param6,/*[in,optional]*/ VARIANT param7,/*[in,optional]*/ VARIANT param8,/*[in,optional]*/ VARIANT param9,/*[in,optional]*/ VARIANT param10, int sendOrPost)
{
	Func *aFunc = g_script.FindFunc(func) ;
	if (aFunc)
	{	
		// g_script.mTempFunc = aFunc ;
		// ExprTokenType return_value;
		if (aFunc->mParamCount > 0 && &param1 != NULL)
		{
			// Copy the appropriate values into each of the function's formal parameters.
			AssignVariant(*aFunc->mParam[0].var, param1, false); // Assign parameter #1
			if (aFunc->mParamCount > 1  && &param2 != NULL) // Assign parameter #2
			{
				// v1.0.38.01: LPARAM is now written out as a DWORD because the majority of system messages
				// use LPARAM as a pointer or other unsigned value.  This shouldn't affect most scripts because
				// of the way ATOI64() and ATOU() wrap a negative number back into the unsigned domain for
				// commands such as PostMessage/SendMessage.
				AssignVariant(*aFunc->mParam[1].var, param2, false);
				if (aFunc->mParamCount > 2 && &param3 != NULL) // Assign parameter #3
				{
					AssignVariant(*aFunc->mParam[2].var, param3, false);
					if (aFunc->mParamCount > 3 && &param4 != NULL) // Assign parameter #4
					{
						AssignVariant(*aFunc->mParam[3].var, param4, false);
						if (aFunc->mParamCount > 4 && &param5 != NULL) // Assign parameter #5
						{
							AssignVariant(*aFunc->mParam[4].var, param5, false);
							if (aFunc->mParamCount > 5 && &param6 != NULL) // Assign parameter #6
							{
								AssignVariant(*aFunc->mParam[5].var, param6, false);
								if (aFunc->mParamCount > 6 && &param7 != NULL) // Assign parameter #7
								{
									AssignVariant(*aFunc->mParam[6].var, param7, false);
									if (aFunc->mParamCount > 7 && &param8 != NULL) // Assign parameter #8
									{
										AssignVariant(*aFunc->mParam[7].var, param8, false);
										if (aFunc->mParamCount > 8 && &param9 != NULL) // Assign parameter #9
										{
											AssignVariant(*aFunc->mParam[8].var, param9, false);
											if (aFunc->mParamCount > 9 && &param10 != NULL) // Assign parameter #10
											{
												AssignVariant(*aFunc->mParam[9].var, param10, false);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		
		FuncAndToken & aFuncAndToken = aFuncAndTokenToReturn[returnCount];
		aFuncAndToken.mFunc = aFunc ;
		returnCount++ ;
		if (returnCount > 9)
			returnCount = 0 ;

		if (sendOrPost == 1)
		{
		SendMessage(g_hWnd, AHK_EXECUTE_FUNCTION_VARIANT, (WPARAM)&aFuncAndToken,NULL);
		return aFuncAndToken.variant_to_return_dll;
		}
		else
		{
			PostMessage(g_hWnd, AHK_EXECUTE_FUNCTION_VARIANT, (WPARAM)&aFuncAndToken,NULL);
			VARIANT &r =  aFuncAndToken.variant_to_return_dll;
			r.vt = VT_NULL ;
			return r ; 
		}
		}
	FuncAndToken & aFuncAndToken = aFuncAndTokenToReturn[returnCount];
	returnCount++ ;

	VARIANT &r =  aFuncAndToken.variant_to_return_dll;
	r.vt = VT_NULL ;
	return r ; 
	// should return a blank variant
}