events with out parameter and CFCOM

windows ce

    Next

  • 1. Method 'CodeDb' object '_Application' failed
    Hello: I am migrating from Acces 2003 to SQL Server 2000 using Access assistant under Windows 2000 Sp4 and I obtained the error: Method 'CodeDb' object '_Application' failed I have reinstalled and repaired but nothing changed. What can I do ? Thanks in advance. My best regards. Roberto
  • 2. Exception launcing processes
    Hi, I'd like understanding why, when I launch a process from inside my application I receive or no an exception, depending on the program I try to launch. This is the code I execute: externApp = System.Diagnostics.Process.Start(fullnameApp, ""); IntPtr hwndExt = IntPtr.Zero; do { System.Threading.Thread.Sleep(500); externApp.Refresh(); hwndExt = externApp.MainWindowHandle; //this line throws InvalidOperationException } while (hwndExt.Equals(IntPtr.Zero)); If fullnameApp = "/Windows/calc.exe", no exception occurr, if instead fullnameApp = "/Windows/iexplore.exe" exception is thrown. Analising both cases with debugging before executing the impeached line I saw that in first case it has exited field and HasExited property = false, instead in the latter, in a first moment exited field is false and HasExited true, but then both became true, even if the process is still alive. Which is the reason of it? Thanks, Andrea
  • 3. Using COM OutProc server on WinCE
    I have an application that uses COM OutProc server and I have to port it to WinCE 5.0 and WinMobile 5.0 and I found out that COM outproc server is not supported on WinCE 5.0. One option for me is to remove COM and implement my own RPC server and client but this might take so is there any way to make existing code work on winCE. I am also using Monikers in my code. aguliani
  • 4. Larger(r) menu Font in Win CE
    Hello! Is there any way to change the menu font in Windows CE and make it larger. Like in Win XP where you can select Display settings / appearance / advanced settings and change the menu font size. Sincerely Toby Andrews
  • 5. How do we change the priority of drivers?
    Hi friends, My problem now is that I need to assign priorities to various drivers. We successfully can use ethernet, wireless ethernet, serial communication(RS232) etc on our project but when i use them together i lose some data(WinCE 5.0 and ICOP Vortex86 6071 embedded card). Since the most important of them is serial communication i need to force kernel to give priority to serial first and then others. How can i do this? What registry values need i change? Any help would be greatly appreciated... Thanks...

events with out parameter and CFCOM

Postby Maarten » Sun, 07 Dec 2003 01:35:48 GMT

Hi,

I have a problem returning a BSTR from a C# COM client to my evc++ COM
server.
I have send an email to CFCOM, but they probably won't answer, they didn't
answer to my previous mail.
Maybe here somebody could help me out, I assume I am not the only CFCOM user
;-).


This is the mail explaining my problem in more detail:

In my project I have an event with an [in,out] BSTR parameter. When I set
the parameter in my C# client using the OutParameter class, nothing is
changed in my COM object. I have tried several things:
- When I pass my [in,out] parameter as a "reference" variable, that doesn't
seem to work. Is it possible that CFCOM can't work with variants of type
VT_BYREF|* ?
- When I pass my parameter as a "by value" variable, everything works in the
direction from COM server to client. But my returned value, isn't correctly
passed to my COM object. It isn't changed.

This is a piece of my code:

MIDL code:
-------------
[id(1), helpstring("method Event")] HRESULT Event([in]BSTR name,
[in,out]BSTR* pargs_result //<-- I have also tried BSTR pargs_result

event handler code:
-------------------
  HRESULT Fire_Event(BSTR name, BSTR * pargs_result)
 {
  CComVariant varResult;
  T* pT = static_cast<T*>(this);
  int nConnectionIndex;
  CComVariant* pvars = new CComVariant[2];
  int nConnections = m_vec.GetSize();

  for (nConnectionIndex = 0; nConnectionIndex < nConnections;
nConnectionIndex++)
  {
   pT->Lock();
   CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
   pT->Unlock();
   IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
   if (pDispatch != NULL)
   {
    VariantClear(&varResult);
    pvars[1] = name;
    pvars[0].vt = VT_BSTR;
    pvars[0].bstrVal = *pargs_result;
    DISPPARAMS disp = { pvars, NULL, 2, 0 };
    pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&disp, &varResult, NULL, NULL);

    // access returned value from event handler:
    BSTR resultString = SysAllocString(pvars[0].bstrVal);
    *pargs_result = resultString;
   }
  }
  delete[] pvars;
  return varResult.scode;
 }

Could you say me what I am doing wrong?

Thanks and kind regards

Maarten



Similar Threads:

1.problem catching events COM server in C# using CFCOM

2.RIS: BINLSVC Event 1101 / Parameter "LegacyNIC"

3.Events with parameters

Is there a way i can add parameters to an event, when i'm posting it
from a thread receiving data to the main thread handling GUI?

4.Using multiple Parameter sets for a Parameter

How do I assign multiple parameter sets to a single parameter?

Thank you.

5.Ambiguous Parameters with multiple Parameter Sets

I'm still scratching my head.  In fact here is another parameter set that
doesn't seem to work like I would expect it.  If I give the runtime a hint
with DefaultParameterSetName="FOO" this example works, but I shouldn't have
to do that.  The real set of parameters that I'm trying to make work is more
complicated.  The DefaultParameterSetName workaround will not work in that
case.

Does anyone have insight into why I'm not seeing parameter set "FOO" in this
example?  I'm also confused on the original question if anyone knows what is
going on there.

Thanks, Alan

    [Cmdlet("Test", "Parameter", SupportsShouldProcess = true) ]
    public class TestParameterCommand : PSCmdlet
    {
        [Parameter( ParameterSetName = "FOO", Mandatory = true ) ]
        [Parameter( ParameterSetName = "BAR", Mandatory = true ) ]
        public string A { get { return a; } set { a = value; } }
        private string a;

        [Parameter( ParameterSetName = "FOO", Mandatory = true ) ]
        [Parameter( ParameterSetName = "BAR", Mandatory = true ) ]
        public string B { get { return b; } set { b = value; } }
        private string b;

        [Parameter( ParameterSetName = "BAR", Mandatory = true ) ]
        public string C { get { return c; } set { c = value; } }
        private string c;
    }

//
// Why doesn't the "Test-Parameter -A abc -B 123" command parse?
// I was expecting Parameter Set Name "FOO"
//

PS C:\> Test-Parameter -A abc -B 123 -C abc123
PS C:\> Test-Parameter -A abc -B 123
Test-Parameter : Parameter set cannot be resolved using the specified named
parameters.
At line:1 char:15
+ Test-Parameter  <<<< -A abc -B 123
PS C:\>






"Alan Taylor" <alan DOT ML @T geemail D_OT com> wrote in message
news:uhw% XXXX@XXXXX.COM ...
> In the example below, I'm confused when the "-e" parameter is marked
> ambiguous.  I have to specify all parameter set names for the command to
> correctly parse.  Is this a bug or intended behavior?
>
>     [Cmdlet("Test", "Parameter", SupportsShouldProcess = true) ]
>     public class TestParameterCommand : PSCmdlet
>     {
>         [Parameter( ParameterSetName = "A_C", Mandatory = true ) ]
>         [Parameter( ParameterSetName = "A_D", Mandatory = true ) ]
>         public string A { get { return a; } set { a = value; } }
>         private string a;
>
>         [Parameter( ParameterSetName = "B_C", Mandatory = true ) ]
>         [Parameter( ParameterSetName = "B_D", Mandatory = true ) ]
>         public string B { get { return b; } set { b = value; } }
>         private string b;
>
>         [Parameter( ParameterSetName = "A_C", Mandatory = true ) ]
>         [Parameter( ParameterSetName = "B_C", Mandatory = true ) ]
>         public string C { get { return c; } set { c = value; } }
>         private string c;
>
>         [Parameter( ParameterSetName = "A_D", Mandatory = true ) ]
>         [Parameter( ParameterSetName = "B_D", Mandatory = true ) ]
>         public string D { get { return d; } set { d = value; } }
>         private string d;
>
>         public string E { get { return e; } set { e = value; } }
>         private string e;
>     }
>
>
> PS C:\> Test-Parameter -a foo -c bar
> PS C:\> Test-Parameter -a foo -d bar
> PS C:\> Test-Parameter -b foo -c bar
> PS C:\> Test-Parameter -b foo -d bar
> PS C:\> Test-Parameter -a foo -c bar -e oops
> Test-Parameter : Parameter cannot be processed because the parameter name
> 'e' is ambiguous. Possible matches include: -
> ErrorAction -ErrorVariable.
> At line:1 char:15
> + Test-Parameter  <<<< -a foo -c bar -e oops
> PS C:\>
>
> //
> // Change the definition of -e to include all parameter sets.  Like this:
> //
> // [Parameter( ParameterSetName = "A_C") ]
> // [Parameter( ParameterSetName = "A_D") ]
> // [Parameter( ParameterSetName = "B_C") ]
> // [Parameter( ParameterSetName = "B_D") ]
> // public string E { get { return e; } set { e = value; } }
> // private string e;
> //
> // The command parses the way I intended it.
> //
>
> PS C:\> Test-Parameter -a foo -c bar
> PS C:\> Test-Parameter -a foo -c bar -e oops
> PS C:\>
>
>


6. Event ID: 1003, Event Type: Error ,Event Source: System Error,Event Category: (102)

7. Source group switching causes script stream drop outs

8. I/O, time-outs?



Return to windows ce

 

Who is online

Users browsing this forum: No registered users and 14 guest