Re: HRESULT return value in Javascript without exception



Try describing your interface method in IDL like this:

HRESULT Testfunc1([out, retval] long *pResult);

and in C++ :

STDMETHODIMP Cwork::Testfunc1(long *pResult)
{
*pResult = 111;
return S_OK;
}


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Rob" <Rob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5FF4D402-603F-46B3-8025-1D9A48D069B3@xxxxxxxxxxxxxxxx
Tried that, but the project (ATL activex) doesn't compile such a member.
It says that all interface members must return HRESULT.

Error, returnvalue, whatever.... ( is S_OK an error? )
What matters to me is that Javascript seems unable to typecast the 4 byte
piece of memory (HRESULT==LONG in C++) that is returned to something
usefull.

Greetings,
Rob.


"bruce barker" wrote:

HResult is meant to return errors, and is not the return value of a
interface. change the com interface to return an int value, then
javascript can access it.

-- bruce (sqlwork.com)

Rob wrote:
Hi,
If I call my own DLL from Javascript, a HRESULT is returned.
Javascript cannot cast this to an integer.
Is there any other way of typecasting this returnvalue to integer,
wihout
using the exception method which is described everywhere ?
Please note that I am unfamiliar with javascript, I am used to C/C++.

My Javascript call looks like :

var result;
result = Testfunc1();

The function is called OK, but the returnvalue cannot be converted.
It is printed as "undefined".
I just need 0 or 1 to be returned (or 2 other values, one for OK, and
one
for ERROR)
So I tried the following :

result = (Testfunc1() & 255) ;

But this always returns 0 for some reason....

It seems unlogical and not neat, to throw exceptions when really
nothing
serious happenned, just to convert the returnvalue. Also the
clientcode will
be poluted with a lot of extra (rather poorly structured) lines.
So If I could just get the low-byte of the HRESULT, this would be
enough for
me.

Please Help !

Greetings,
Rob.
























.



Relevant Pages

  • Re: HRESULT return value in Javascript without exception
    ... If I call my own DLL from Javascript, a HRESULT is returned. ... using the exception method which is described everywhere? ... but the returnvalue cannot be converted. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HRESULT return value in Javascript without exception
    ... It says that all interface members must return HRESULT. ... What matters to me is that Javascript seems unable to typecast the 4 byte ... If I call my own DLL from Javascript, a HRESULT is returned. ... Is there any other way of typecasting this returnvalue to integer, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HRESULT return value in Javascript without exception
    ... HResult is meant to return errors, and is not the return value of a interface. ... If I call my own DLL from Javascript, ... but the returnvalue cannot be converted. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HRESULT return value in Javascript without exception
    ... If I call my own DLL from Javascript, a HRESULT is returned. ... using the exception method which is described everywhere? ... but the returnvalue cannot be converted. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: UI toolkits for Python
    ... nowadays can offer a rich graphical interface, it can be quite difficult to manage state maintenance between the two components (web server, web client) in the system. ... As has already been said, with the adoption of standards like CSS2, it's even possible to make such stuff run across multiple browser platforms (at the moment, though, just try writing an interface that makes table rows appear and disappear in a cross-browser fashion: you'll find the stylesheet techniques you need to use for Mozilla and IE are very different). ... But this doesn't help you at all if you are trying to interface to Python logic. ... already a HTML and JavaScript driven server platform and know about problems with the back-button and sessions. ...
    (comp.lang.python)

Quantcast