|
No need to be abusive, it was a perfectly reasonable question. You would be amazed (or maybe not) at the number of people who do none.
|
|
|
|
|
getting heated 
|
|
|
|
|
I want to get the context menu items on the mail item(outbox of outlook) programmatically from my outlook add-in. I ideally want to programmatically in C# get the context menu item on a mail item and perform invoke operation on the custom context menu item say "MyContextMenuItem". Everything getting context menu on mail item, iterating to find my item and performing the click, should happen programmatically. I googled around and found to add context item but not able to retrieve programmatically. Your reply would be of great help.Please Find the attachment for more details.
Thank you..
|
|
|
|
|
Why is it that this native code works to create an IShellLink object:
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
But this managed code throws "COM Error: Class not registered"
var Link = new Shell32.ShellLinkObject();
In the C# project I have a reference to Shell32. I'm on Windows 10 x64 and I have the C# project set to build for "Any CPU".
So what's the problem here?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I'm writing a COM server exe using CLSCTX_LOCAL_SERVER as below.
1. COM Server
. Use IDL language to define a interfaceID, classID.
. Call CoRegisterClassObject to register a factory object
. I designed COM Server source code as below
class CMyFactory : public IClassFactory
{
};
class CMyObj : public IUnknown
{
-----class XSubClass : public IMyInterface
-----{
-----}m_subClass;
-----friend class CMyObj;
}
Before starting COM Server, I call CoRegisterClassObject to register factoryObject to system.
2. COM Client
. IMyInterface* pObj;
. CoGetClassObject(CLSID_CoMyObj, CLSCTX_LOCAL_SERVER, NULL, IID_IClassFactory, (void **) &pFac);
. pFac->CreateInstance(NULL,IID_interfaceID,(void**)&pObj);
However, the result of CreateInstance calling is "E_NOINTERFACE No such interface supported".
Could you please tell me the way to solve it?
|
|
|
|
|
|
But it doesn't mention about COM Local sever
|
|
|
|
|
|
Dear All,
I am doing some development with a Logitech C920. I tried to maximize the resolution of C920 to 1920X1080, which it can support. The setting is successful as hr is S_OK. Then I use a samplegrabber to get the image, which is always 640X480. Something is wrong. I am brand new to DirectShow. All my code is based on other's sample code. So, could anyone give me a help?
Best,
Gary
/////////////////////////////////////////////////////////////
void videoCapture::SetResolution(IBaseFilter* pSrcFilter, int Width, int Height)
{
IAMStreamConfig *pConfig = NULL;
pCapture->FindInterface(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, pSrcFilter, IID_IAMStreamConfig, (void**)&pConfig);
int resolutions, size;
VIDEO_STREAM_CONFIG_CAPS caps;
pConfig->GetNumberOfCapabilities(&resolutions, &size);
for (int i = 0; i < resolutions; i++)
{
AM_MEDIA_TYPE *mediaType;
if (pConfig->GetStreamCaps(i, &mediaType,
reinterpret_cast<byte*>(&caps)) == S_OK)
{
int maxWidth = caps.MaxOutputSize.cx;
int maxHeigth = caps.MaxOutputSize.cy;
if (maxWidth == Width && maxHeigth == Height)
{
VIDEOINFOHEADER *info = reinterpret_cast<videoinfoheader*>(mediaType->pbFormat);
info->bmiHeader.biWidth = maxWidth;
info->bmiHeader.biHeight = maxHeigth;
info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader);
HRESULT hr = pConfig->SetFormat(mediaType);
DeleteMediaType(mediaType);
break;
}
DeleteMediaType(mediaType);
}
}
SAFE_RELEASE(pConfig);
}
/////////////////////////////////////////////////////////////
HRESULT videoCapture::CaptureVideo(unsigned int devIndex)
{
if (devIndex == 0)
devIndex = 1;
HRESULT hr;
IBaseFilter *pSrcFilter = NULL;
// Attach the filter graph to the capture graph
hr = pCapture->SetFiltergraph(pGraph);
if (FAILED(hr)) {
Msg(TEXT("Failed to set capture filter graph! hr=0x%x"), hr);
return hr;
}
// Use the system device enumerator and class enumerator to find
// a video capture/preview device, such as a desktop USB video camera.
hr = FindCameraDevice(&pSrcFilter);
if (FAILED(hr)) {
// Don't display a message because FindCaptureDevice will handle it
return hr;
}
// Add Capture filter to our graph.
hr = pGraph->AddFilter(pSrcFilter, L"Video Capture");
if (FAILED(hr)) {
Msg(TEXT("Couldn't add the capture filter to the graph! hr=0x%x\r\n\r\n")
TEXT("If you have a working video capture device, please make sure\r\n")
TEXT("that it is connected and is not being used by another application.\r\n\r\n")
TEXT("The sample will now close."), hr);
SAFE_RELEASE(pSrcFilter);
return hr;
}
hr = SetCameraExposure(pSrcFilter, 100);
hr = pImageGrabber->InitSampleGrabber(pGraph);
if (FAILED(hr)) {
Msg(TEXT("Couldn't add the SampleGrabber filter to the graph! hr=0x%x"), hr);
return hr;
}
hr = pImageGrabber->SetSampleGrabberMediaType();
if (FAILED(hr)) {
Msg(TEXT("Couldn't set the SampleGrabber media type! hr=0x%x"), hr);
return hr;
}
SetResolution(pSrcFilter, 1920, 1080);
IBaseFilter* pGrabber = pImageGrabber->GetSampleGrabber();
hr = pCapture->RenderStream(NULL, &MEDIATYPE_Video,
pSrcFilter, pGrabber, NULL);
hr = pImageGrabber->GetSampleGrabberMediaType();
if (FAILED(hr)) {
Msg(TEXT("Couldn't get the SampleGrabber media type! hr=0x%x"), hr);
return hr;
}
// Now that the filter has been added to the graph and we have
// rendered its stream, we can release this reference to the filter.
SAFE_RELEASE(pSrcFilter);
#ifdef REGISTER_FILTERGRAPH
// Add our graph to the running object table, which will allow
// the GraphEdit application to "spy" on our graph
hr = AddGraphToRot(g_pGraph, &g_dwGraphRegister);
if (FAILED(hr)) {
Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
g_dwGraphRegister = 0;
}
#endif
// Start previewing video data
hr = pMC->Run();
if (FAILED(hr)) {
Msg(TEXT("Couldn't run the graph! hr=0x%x"), hr);
return hr;
}
return S_OK;
}
|
|
|
|
|
I have built a COM DLL with a number of functions in version 1:
- OnlineAvailCheck_V2 --> first public function
- DownloadProductInfo_V2 --> second public function
- DownloadPriceInfo_V2 --> third public function
The COM DLL is called from an external application; the functions appear in the same order as shown above.
In version 2, the DownloadProductInfo function has become obsolete, and needs to be replaced by V31
- OnlineAvailCheck_V2 --> first public function
- DownloadProductInfo_V2 --> becomes private
- DownloadPriceInfo_V2 --> second public function
- DownloadProductInfo_V31 --> third public function
If I make the V2 function private (because it must no longer be used), the external application makes a shift in the code: all references to DownloadProductInfo_V2 are now replaced by references to the third public function, i.e. DownloadPriceInfo_V2 function.
Is there any way I can give a fixed sequence number to the functions, so that I can avoid the shift? Or is there any other way to deal with this? Thank you.
Dox Girl, where are you?
|
|
|
|
|
Use the DispIdAttribute attribute[^] to specify the COM dispatch identifier for your methods and properties. That way, the order doesn't matter.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As a side note, once interfaces are defined they should be fixed unless you are willing to re-compile all clients also. So if you want to alter the interface you should re-compile your client too. If you don't want to re-compile the client, then implement a new interface and have calls to your old interface redirect or forward to the method on the new interface. The redundant methods will just remain there, you can have them return errors if you want to indicate they shouldn't be called. Any new client, or client you don't mind re-compiling, will reference your new interface. This way all old and new clients still see the interfaces they were compiled against.
You might be able to configure the interface forwarding for you automatically using the registry, it's been a while and back in the day interface forwarding was handled by the compiled and COM registration tools.
|
|
|
|
|
Hi all,
I am trying to control the Undo/Redo Stack in excel but I can't seem to get a pointer to the UndoManager Interface in the ppv out argument when calling the QueryService Method .. it always returns Nothing ..
I hope someone can tell me what I am doing wrong .. I think the "SID_SApplicationObject" is not the right SID
Note : I am using the olelib.tlb
Code :
Sub Test()
Dim pUnk As olelib.IUnknown
Dim IServiceProvider As olelib.IServiceProvider
Dim IID_IServiceProvider As olelib.UUID
Dim IID_IOleUndoManager As olelib.UUID
Dim SID_SApplicationObject As olelib.UUID
Dim ppv As IUnknown
CLSIDFromString IIDSTR_IServiceProvider, IID_IServiceProvider
CLSIDFromString "{0C539790-12E4-11CF-B661-00AA004CD6D8}", SID_SApplicationObject
Set pUnk = Excel.Application
pUnk.QueryInterface IID_IServiceProvider, IServiceProvider
IServiceProvider.QueryService SID_SApplicationObject, IID_IOleUndoManager, ppv
End Sub
Any help will be much appreciated
Regards.
|
|
|
|
|
The following code is supposed to redirect the call to the Excel Calculate Method to my own function (MeMsg)
After running the HookCOMFunction routine , the Test Macro successfully executes the MeMsg replacement function as expected .. So far so good
However, when executing an excel calculation via the User Interface (not via code) such as by pressing the F9 key , the MeMsg replacement function doesn't get called ... I thought that replacing the 'Calculate' VTable offset address with the address of my replacement function would also work everytime excel is calculated via the User Interface
Any thoughts anyone ? My goal is to hook the excel Calculate Method via code as well as via the UI
Regards.
Code :
Option Explicit
Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long _
)
Private Declare Function VirtualProtect Lib "kernel32.dll" ( _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flNewProtect As Long, _
lpflOldProtect As Long _
) As Long
Private Const PAGE_EXECUTE_READWRITE As Long = &H40&
Sub HookCOMFunction()
Dim pVTable As Long
Const lFuncOffset As Long = 84
CopyMemory pVTable, ByVal ObjPtr(Application), 4
VirtualProtect pVTable + lFuncOffset, 4&, PAGE_EXECUTE_READWRITE, 0&
CopyMemory ByVal pVTable + lFuncOffset, AddressOf MeMsg, 4
End Sub
Private Function MeMsg(ByVal voObjPtr As Long, ByVal Param As Long) As Long
MsgBox "Excel 'Calculate Method Hooked !!"
End Function
Sub Test()
Application.Calculate
End Sub
|
|
|
|
|
Bump ..
Any thoughts on this anyone ?
|
|
|
|
|
I have created a COM object in VS2013. I can call it from VBA late-bound. I want to be able to call it early-bound. However, the COM object name shows twice in the reference list. Likt this:
[books icon] COMName
[object icon] COMName
If I try to early bind I get a compile error:
Expected user-defined type, not project
How can I get around this?
Thanks,
Crew
|
|
|
|
|
Sorry friends. This's a guide.
The Windows Scripting Host (WSH) enables a number of file system and network operations to be performed from a script file. Fortunately, it is very simple to directlyprogram the WSH in a .NET program by including a reference to the WSH runtime library (IWshRuntimeLibrary). To do this within the Visual Studio .NET IDE, do the following:
After creating a new project
- right-click on the project name within the Solution Explorer
- select "Add Reference"
- select the "COM" tab, find and select the "Windows Script Host Object Model" in the listbox
- click "Select", and then click "OK". Next, include a reference to the library
|
|
|
|
|
|
I have a very simple dot net library that uses COM Interop and a simple test program in VB that uses CreateObject to instantiate the COM component.
This works fine if I register the dot net library using REGASM but I cannot get it to work with a side by side manifest. I tried creating the manifest manually as well as using a number of different tools. The manifests look fine but it is unable to create the COM object.
Is there anything special I am missing? any ideas what to look for?
thanks
Mike
|
|
|
|
|
You have to register your component using regasm and you can't do things like side-by-side. Although your component is written in .net, it is exposing itself via COM and COM is registry based and you can't leverage .net features like just loading assemblies from a directory. When you use REGASM it creates the required registry entries that give the exact location of your assembly to load when a COM client asks for your component.
|
|
|
|
|
Not true. COM works with side x side. I've done it myself but have to confess it is a while since I have done it. (Only visiting the COM forum for nostalgia)
|
|
|
|
|
I meant COM doesn't work easily side-by-side in the .net sense, but yes you can use the sxs framework to make side by side com assemblies. However re-reading the original question I think he was talking about registration free COM manifest files over standard registry-based registration.
https://msdn.microsoft.com/en-us/library/fh1h056h(v=vs.110).aspx[^]
But I think that only applies to .net clients, not the likes of VB.
|
|
|
|
|
Hi,
Please if some help me to find the solution or some inputs
i am interested to subclass Content Control or rather i will
say i am in need to create my custom control which will have same behavior as Content Control ,
how can i go for it i need in C++ /ATL/Com dont like to use clr c++ or any other .
if some one can help me .
|
|
|
|
|
COSERVERINFO si;
si.dwReserved1=0;
si.pwszName=szIP;
si.pAuthInfo=NULL;
si.dwReserved2=0;
IID iid=__uuidof(ITCSUser);
MULTI_QI qi={&iid,0,0};
HRESULT hRes=CoCreateInstanceEx(__uuidof(TCSUser),NULL,CLSCTX_REMOTE_SERVER,&si,1,&qi);
if (FAILED(hRes))
{
Log(_T("Can't create user object, error 0x%.8X"),hRes);
return false;
}
I am developing a third party app by using this so-called TCS Api, the GUID of both class and interface(ITCSUser,CTCSUser) can be found in registry. while the CLASSNOTREG error will be generated after executing CoCreateInstanceEx. I have been stuck here so long and not yet figure it out. I am a beginner of COM/DCOM, could anyone help or give a little hint. By the way, this app is run on Windows server 2008 r2, someone told me the OS is not supported DCOM. Is this really mattered?
|
|
|
|
|
Billy Bang wrote: this so-called TCS Api, If this is a third-party product you might want to talk to the people who create it.
Also check in your code that all parameters are correct, particularly the value returned by __uuidof(TCSUser) .
|
|
|
|
|