Discussion:
Microsoft JScript runtime error: Invalid procedure call or argument error while calling functions in an interface
(too old to reply)
Subhashini
2005-07-20 12:23:07 UTC
Permalink
Hi
I am newbie to scprting languages.
We have some interfaces and when I'm trying to call functions in them
using Jscript , they are failing with " Microsoft JScript runtime
error: Invalid procedure call or argument ".
Below is my program and my idl file. I am able to call some functions
but when I have to pass some GUID or pointers, its failing. How do I
pass arguments like these?

Please help me out.

Thanks
Subhashini


==============================­======
// My Jscript
var testGUID = "{A456F5EA-D718-42d6-B858-62F8­2A143456}";


function GetTotalProfiles()
{
NumProfiles=ProfileMgr.GetNumP­rofiles();
WScript.Echo("Total Profiles = "+NumProfiles);
return NumProfiles;


}


function GetProfiles()
{

totalProfiles= GetTotalProfiles();
WScript.Echo("Profiles ="+totalProfiles);
var NumProfiles=0;
profiles=profileMgr.GetProfile­sforDeviceID"0002",totalProfil­es);
///This is working
var profileName=profiles.GetName()­; //This is also working
WScript.Echo("profile name="+ profileName);
var ppid;
profiles.GetProperty(nopropId,­ppid); // GetProperty giving error :
Microsoft JScript runtime error: Invalid procedure clal or agrument
profiles.GetGUID(); // GETGUID giving error Microsoft JScript runtime
error: Invalid procedure call or agrument
}


function CreateProfile()
{
var profile;
WScript.Echo("Create Profile");
profile=ProfileMgr.CreateProfi­le("0002","Test Profile",testGUID);

// CreateProfile ginving error "Microsoft JScript runtime error:
Invalid procedure call or agrument "
var ProfileName=profile.GetName();
WScript.Echo("profile name="+ profileName);

}


GetProfiles();

===========================


IDL file looks like this


interface IProfileMgr : IDispatch
{
HRESULT GetProfilesforDeviceID([in] BSTR bstrDeviceID, [ref,in,out]
ULONG * pulNumProfiles, [out,retval] IProfile ** ppProfile);
HRESULT GetNumProfiles([out,retval] ULONG * pulNumProfiles);
HRESULT CreateProfile([in] BSTR bstrDeviceID, [in] BSTR bstrName,
[in] GUID guidCategory, [out,retval] Iprofile ** ppprofile);



}


interface IProfile : IDispatch
{
HRESULT GetProperty([in] ULONG num, [ref,in] PROPID * pid,
[out,retval] PROPVARIANT * pvar);
HRESULT GetGUID([out,retval] GUID * pGUID);
HRESULT GetName([out,retval] BSTR * pbstrName);
unknown
2005-07-20 12:42:02 UTC
Permalink
Post by Subhashini
Hi
I am newbie to scprting languages.
We have some interfaces and when I'm trying to call functions in them
using Jscript , they are failing with " Microsoft JScript runtime
error: Invalid procedure call or argument ".
Below is my program and my idl file. I am able to call some functions
but when I have to pass some GUID or pointers, its failing. How do I
pass arguments like these?
Please help me out.
Thanks
Subhashini
==============================­======
// My Jscript
var testGUID = "{A456F5EA-D718-42d6-B858-62F8­2A143456}";
function GetTotalProfiles()
{
NumProfiles=ProfileMgr.GetNumP­rofiles();
WScript.Echo("Total Profiles = "+NumProfiles);
return NumProfiles;
}
function GetProfiles()
{
totalProfiles= GetTotalProfiles();
WScript.Echo("Profiles ="+totalProfiles);
var NumProfiles=0;
profiles=profileMgr.GetProfile­sforDeviceID"0002",totalProfil­es);
///This is working
var profileName=profiles.GetName()­; //This is also working
WScript.Echo("profile name="+ profileName);
var ppid;
Microsoft JScript runtime error: Invalid procedure clal or agrument
profiles.GetGUID(); // GETGUID giving error Microsoft JScript runtime
error: Invalid procedure call or agrument
}
function CreateProfile()
{
var profile;
WScript.Echo("Create Profile");
profile=ProfileMgr.CreateProfi­le("0002","Test Profile",testGUID);
Invalid procedure call or agrument "
var ProfileName=profile.GetName();
WScript.Echo("profile name="+ profileName);
}
GetProfiles();
===========================
IDL file looks like this
interface IProfileMgr : IDispatch
{
HRESULT GetProfilesforDeviceID([in] BSTR bstrDeviceID, [ref,in,out]
ULONG * pulNumProfiles, [out,retval] IProfile ** ppProfile);
HRESULT GetNumProfiles([out,retval] ULONG * pulNumProfiles);
HRESULT CreateProfile([in] BSTR bstrDeviceID, [in] BSTR bstrName,
[in] GUID guidCategory, [out,retval] Iprofile ** ppprofile);
}
interface IProfile : IDispatch
{
HRESULT GetProperty([in] ULONG num, [ref,in] PROPID * pid,
[out,retval] PROPVARIANT * pvar);
HRESULT GetGUID([out,retval] GUID * pGUID);
HRESULT GetName([out,retval] BSTR * pbstrName);
are you doubleclicking the js files? it wont work that way
Subhashini
2005-07-20 13:17:02 UTC
Permalink
I am running from the cmd window as "Profiles.js"

How should I run then ???
Dave Methvin
2005-07-20 17:49:09 UTC
Permalink
Post by Subhashini
We have some interfaces and when I'm trying to call
functions in them using Jscript , they are failing with
" Microsoft JScript runtime error: Invalid procedure
call or argument ".
HRESULT GetProfilesforDeviceID(
[in] BSTR bstrDeviceID,
[ref,in,out] ULONG * pulNumProfiles,
[out,retval] IProfile ** ppProfile);
If you want to be compatible with JScript the only fully compatible types
are [in] and [out,retval]. It looks like you're trying to return an "array
of objects", the best scripting-friendly way to do that might be with a COM
collection. Here's one article about them, although there are probably
better ones:
http://www.codeproject.com/atl/com_collection.asp
Post by Subhashini
HRESULT GetGUID([out,retval] GUID * pGUID);
[ref,in] PROPID * pid,
To be usable in scripting, the args need to resolve to something that can be
stored in a VARIANT. Maybe you could convert the GUID or PROPID to a string?
Continue reading on narkive:
Search results for 'Microsoft JScript runtime error: Invalid procedure call or argument error while calling functions in an interface' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...