|
I want to know general question for using com and dcom ...
Is there any article that talks about com and dcom for beginners using c#
i am search in google but not find any simple article , plz help me ?
|
|
|
|
|
Hi
I have successfully got Directshow outputing a video from C++ MFC using Sample Grabber, but I can not figure out how to play the audio with this.
I have attached code snippet of what I have done currently, can anyone tell me what I need to do to get audio stream to work. I have added the sound renderer filter, just dont know how to connect it with the rest of the graph.
Thanks
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent);
hr = pGraph->QueryInterface(IID_IBasicAudio, reinterpret_cast<void**>(&m_pAudio));
hr = pGraph->QueryInterface(IID_IMediaSeeking, reinterpret_cast<void**>(&pSeeking));
hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF);
if (FAILED(hr))
{
// Return an error.
}
hr = pGraph->AddFilter(pGrabberF, L"Sample Grabber");
CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSoundRenderer);
hr = pGraph->AddFilter(g_pSoundRenderer, NULL);
// hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF);
// hr = pGraph->AddFilter(
if (FAILED(hr) )
{
// Return an error.
}
pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber);
//ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Stream;
//mt.subtype = GUID_NULL;//MEDIASUBTYPE_RGB24;
hr = pGrabber->SetMediaType(&mt);
hr = pGraph->AddSourceFilter(fileName.AllocSysString(), L"Source", &pSrc);
if (FAILED(hr))
{
// Return an error code.
}
hr = ConnectFilters(pGraph, pSrc, pGrabberF);
// Create the NULL renderer and connect
hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, reinterpret_cast<void**>(&m_pNullRenderer));
hr = pGraph->AddFilter(m_pNullRenderer, L"NullRenderer");
hr = ConnectFilters(pGraph, pGrabberF, m_pNullRenderer);
|
|
|
|
|
Can someone help me with this error? I am compiling an IDL file and am getting an MIDL2020 error. This error is defined as
"General access denied error". I am working on a Windows Vista machine and have searched for a solution but cannot find anything that solves this. Any suggestions would be greatly appreciated. Below is the complete compilation error:
midl\oleaut32.dll : error MIDL2020 : error generating type library : SaveAllChanges Failed : .\spellcheck.tlb (0x80070005)
Here is the program:
//Creating the interface
import "unknwn.idl";
[object,uuid(C73BA5B4-B466-4348-8CC2-E6B48998B3F7)]
//Defining the interface
interface ISpellChecker : IUnknown
{
HRESULT CheckSpelling([in,string] char *word,[out,retval] BOOL *isCorrect);
HRESULT UseCustomDictionary([in,string] char *filename);
}
//Define type library
[uuid(C81C9C52-008B-429d-8533-262E90A1D0D5)]
library SpellcheckerLib
{
[uuid(57B7A8A0-E4D7-11d0-818D-444553540000)]
coclass CSpellChecker
{
interface ISpellChecker;
}
};
modified on Sunday, May 30, 2010 10:46 AM
|
|
|
|
|
I obtained the answer for this on another board. Basically, the problem is that I did not sign-on as administrator on my Visual Studio program.
|
|
|
|
|
Something puzzling is happening and I don't understand why. I tested using both my C# and VB.NET test apps and both result in the same behavior. When I run the application I have the following line (C#):
m_COMApp = new SignalServer.Application();
No matter what I do, I always get a new instance of the COM server, even if the server is already up and running. This does not happen in XP and I don't recall it ever happening under Vista (I plan to re-test that this weekend as I have Vista at home). This only happens when I run the COM client directly from within Visual Studio. I even changed my reference to point to another version of the server, and it still wanted to load the server found in the original directory.
I decided to run the application by double-clicking in Explorer and then I get the expected behavior. That is, if a server is already running, it will simply attach to the currently running server. Anyone know why I get the other behavior? Some thoughts are:
1) I am on Visual Studio 2005. Maybe this won't happen in 2010.
2) All the applications are 32-bit apps and the OS is 64-bit. Maybe because of the x86 directory names, things get a little messed up?
Anyone else experience this? Thanks for any information.
|
|
|
|
|
Are you running Visual Studio with UAC elevation?
Best Wishes,
-David Delaune
|
|
|
|
|
Aha! Thanks. That was the problem. I turned off UAC and everything works just as I would expect (like on XP)! I always leave UAC turned on because it's great for finding issues our customers will run into. I didn't even think about turning it off this time around.
|
|
|
|
|
Hi,
I am working on Excel Automation.
Implemented the logic to retrieve all the running Excel instances, now I am getting IDispatch pointer. Assigning this IDispatch Pointer to Excel object.
Following is the code:
IDispatch* p=NULL;
HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, __uuidof(IDispatch), (void**)&p);
if(hr == S_OK)
{
try
{
Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(__uuidof(IDispatch),(void**)&pWindow);
Excel::_ApplicationPtr xl;
xl = pWindow->Application;
But getting com exception at above line. The com error: _Vfpointer: scalar deleting destructor(unsigned int) m_hresult:"Member not found".
I googled but there is no clarity in solution.
If any clue, please let me know.
Thanks in Advance.
Regards,
KTTransfer.
|
|
|
|
|
KTTransfer wrote: Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(__uuidof(IDispatch),(void**)&pWindow);
What's the deal with this? You'd hope Excel::WindowsPtr wraps an IDispatch pointer (does it?).
Try this:
Excel::WindowsPtr pWindow = NULL;
HRESULT hr = p->QueryInterface(&pWindow);
Steve
|
|
|
|
|
I tried this,in this case I am getting "hresult hr" as "E_NOINTERFACE".
|
|
|
|
|
I'd take it at its word.
Steve
|
|
|
|
|
Hi,
I created windows application which reads the text file and loads into datagridview on clicking Open button. I would like to use this windows app in Internet Explorer browser. I created the below html and tried to access in IE. The design was shown perfectly and I clicked on Open button and selected text file in File Dialog box and I got the below exception. I found several posts regarding this issue in google. But those didn't solved the problem. Please guide me to resolve this issue. Thanks in advance..
Exception: "application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system admistrator or use the Microsoft .NET Framework Configuration tool."
<html>
<body color=white>
<hr>
<font face=arial size=1>
<OBJECT id="myControl1" name="myControl1" classid="ActiveXDotNet.dll#ActiveXDotNet.myControl" width=800 height=450>
</OBJECT>
</font>
<hr>
</body>
</html>
ActiveXDotNet.dll is the application dll
ActiveXDotNet is the namespace
myControl is the class name
|
|
|
|
|
Hi,
I have an outproc server Executable which exposes an
Interface IServicer.
IServicer has a Method GetBytArray([in]BYTE* bytArray).
This method has to get a Byte array from client and
utilise the values of the array.
When iam calling this Interface method from client by
passing a byte array of size 10, at the server iam
only able to access the first element of the array.
i.e only first element of the array is marshalled from
client to Server. This is happening only in the case of
OUTPROC Servers. How can i access the entire BYTE array
without utilising VARIANT or SAFEARRAY concepts?
modified on Tuesday, May 18, 2010 1:00 AM
|
|
|
|
|
Where is the size_is[^] attribute (and others like length_is )? Given the client and server are in different address spaces clearly this information is required (COM isn't psychic).
Steve
|
|
|
|
|
Hi Steve,
Thanks for the Info.
I tried using Size_is option. Still nor working.
Can you give me a working Client Server Code?
Thanking you.
Arun
|
|
|
|
|
Did you register the proxy-stub? I'm betting no! Anyway I hacked this together:
The client:
#include "stdafx.h"
#import "../Server/Debug/Server.tlb" no_namespace
void DoIt()
{
IServicerPtr p;
HRESULT hr = p.CreateInstance(__uuidof(Servicer));
if (SUCCEEDED(hr))
{
BYTE data[] = {1, 2, 3, 4, 3, 2, 1};
p->SetData(sizeof(data), data);
}
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CoInitialize(NULL);
DoIt();
CoUninitialize();
return 0;
}
The server's IDL (extract).
[
object,
uuid(3D71D2F1-E297-4B26-B2AC-32EA22EFC2B4),
helpstring("IServicer Interface"),
pointer_default(unique)
]
interface IServicer : IUnknown{
[helpstring("method SetData")] HRESULT SetData([in] ULONG size, [in, size_is(size)] BYTE * pData);
};
The server (extract):
STDMETHODIMP CServicer::SetData( ULONG size, BYTE * pData)
{
ostringstream oss;
for (ULONG i=0; i<size; ++i)
{
oss << static_cast<int>(pData[i]) << " ";
}
MessageBoxA(NULL, oss.str().c_str(), "Server", MB_OK);
return S_OK;
}
Steve
|
|
|
|
|
Hi Steve,
Thanks a lot for the code.
How to register the Proxy-Stub of my Outproc dll or exe?
|
|
|
|
|
What development environment are you using? What frameworks (if any) are you using to build the COM servers?
Steve
|
|
|
|
|
Im using Visual Studio 2003. In that i have taken an ATL Project.
Server type is: Service(exe) which exposes IServicer interface.
|
|
|
|
|
I built mine with 2008. What projects are in the workspace? Is there a project to build the proxy-stub (name ends in "PS")?
Steve
|
|
|
|
|
I have a Project named BytComp and BytCompPS in my workspace.
I built the BytCompPS and found ByCompPS.dll and registered it
using regsvr32 command.
Now, i have added a new interface method as suggested by you
but still im not able to access the entire array. 
|
|
|
|
|
Paste the code highlights as I did. Also, building the proxy-stub should have included a post-build step that registered it, so you shouldn't need to do it manually.
Steve
|
|
|
|
|
Hi Stephen,
What do you mean by Code highlights?
|
|
|
|
|
|
Ya i did the same way by copying you code.Still not able to
access the entire array.
Can you send me a working client server codes developed in VC98 or VS2003?
My Id: k_arunkumar_1217@yahoo.com
|
|
|
|
|