|
Howdy, I built an app that used ODBC to write to an SQL database. The client has just turned around and said that they wish to use OLEdb connection strings to tell my app where the server is (instead of ODBC DSNs).
Everything I've found on using OLEDB to access databases, is a whole pile of COM interface stuff with no real world examples. A far cry from the 'CDatabase' simplicity I'm used to.
Can anybody help me with this ?
All I need to do is to write some data via INSERT statements and do a few SELECT statements. I'm looking for some sample code or a tutorial with "real world" examples. Actually, anything that will help me do this in the few hours I have available to change my code.
Thanks to anybody who can help.
Damian Del Campo
|
|
|
|
|
Greetings,
I created an activex control, and now I was wondering how I can have the control get downloaded from a web server if it doesn't exist on a client.
For example some ActiveX controls are downloaded for internet pages when you surf on them. Is there a way to do this?
Thanks in advance
|
|
|
|
|
It seems that after I made the post, I figured out the solution to my problem.
Basically all you have to do is add CODEBASE to your object tag in the HTML file that the Activex control is being used in.
ie: <object="clsid:...ect................"
codebase="http://Myserver/fileblah.dll">
This enables the activex control to be downloaded if it doesn't exist on the machine from the web server page location that is specified in the codebase parameter.
|
|
|
|
|
Hi I am interested in finding out how to build COM objects in Visual Studio.net. I hae done some COM objects before using VB6, but I was told that you now do not have to register dlls or something in 2000 with .net
I heard that at a class on Applications Center Server. They said COM objects are registered in an XML name space or something. I was wondering if anyone had any articles or info on building COM objects in VS.net
Any help would be appreciated
|
|
|
|
|
I've been trying to rotate a bitmap with the DDBLTFX structure. I cleared the structure and set dwRotateAngle, but when I added the DDBLT_ROTATIONANGLE flag the screen went blank.
No errors come to mind.
I also tried setting the DDFXCAPS_BLTROTATION flag in the DDCAPS structure - no luck.
Anyone got an idea? maybe some source code so I could see if I missed anything?
Isaac Sasson,
Lean, mean posting machine!
Sonork ID 100.13704
|
|
|
|
|
Hi !
I'm making an ATL object with VC++. In the interface (.IDL), I added manually a 'typedef enum'.
I also added a class to my ATL project, and I would like to use in this class the 'typedef enum' that I declared in my interface. But I have no idea what file I have to include.
Anyone knows how to use interface-defined type in other classes ?
Thanks for your help !
Jerome
|
|
|
|
|
1. You can use typelib of that COM object using "#import"
2. You can use stub/proxy files generated by midl compiler when you build that object, those file names have pattern (based on "my_com_lib.idl"):
"my_com_lib.h", "my_com_lib_i.c", "my_com_lib_p.c"
soptest
|
|
|
|
|
Thank you for your help. I'm now able to reuse these types defined in my interface in a C++ Class.
I'm now trying to use my COM object in a Visual Basic application, but I cannot declare a variable of a type defined in my interface.
For example, in my IDL, I have :
typedef struct { long val1; long val2; } Try1;
and in VB, I'd like to do something like :
Private myVar As Try1
But Try1 is not recognized.
Do you know how I could do that ?
Thanks !
Jerome
|
|
|
|
|
must include structure declaration in "library" namespace.
Example :
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(0A4ACE5D-612E-11D6-A110-00B0D0C3D9BD),
dual,
helpstring("ITD Interface"),
pointer_default(unique)
]
interface ITD : IDispatch
{
};
[
uuid(0A4ACE51-612E-11D6-A110-00B0D0C3D9BD),
version(1.0),
helpstring("TypeD 1.0 Type Library")
]
library TYPEDLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
/************* My structure for VB *******************/
typedef [uuid(0345C658-6444-11D6-A270-0469D0C3D9BD), helpstring("My struct")]
struct
{
long lVal1;
long lVal2;
} MyInternalStruct;
/************* My structure for VB *******************/
[
uuid(0A4ACE5E-612E-11D6-A110-00B0D0C3D9BD),
helpstring("TD Class")
]
coclass TD
{
[default] interface ITD;
};
};
*******************************************************
This is VB code:
Dim t As TYPEDLib.MyInternalStruct
soptest
|
|
|
|
|
Hi,
I've written a small code (the one given in
MSDN) for capturing video from a camera...
The problem is that i can capture it well..
but when i press the stop button.. the
Camera is not switched off..
Can anybody tell me why???
I am using DirectX (DirectShow)
Please help
Sameer
|
|
|
|
|
I want to overwrite the OnDraw of my ATL composite control, to prevent flickering when redrawing. I thought I could just overwrite the CComCompositeControl::OnDraw, but it seems this method is never called, instead the OnPaint of CAxHostWindow is called, which does not call the OnDraw as the OnPaint of the CCompositeControl does.
Anyone got an idea how to do this ???
|
|
|
|
|
I have a DLL which talks to an EXE server via connection points. If the DLL is killed it doesn't release it's connection with the server so the server stays running.
The EXE has an array of IDispatch pointers, one for each connection. How can I test to see if the IDispatch pointer is still valid? Should I just make a bogus call to Invoke?
This is an ATL project.
Todd Smith
|
|
|
|
|
Yes, make a call, and check HRESULT.
soptest
|
|
|
|
|
I have a web application that utilizes a large assortment of client side COM DLL's written in ATL COM. One of the components is a COM server (EXE) written to be Single Instance (at least in the class factory). It's a multi-threaded apartment to accomplish all the tasks required of it. Therefore, to be useable by scripting languages like VB Script and JavaScript it needs a wrapper object written as an STA. This "Interface" object is a COM DLL that either starts the COM server or connects to a running instance. In this way, many of the interface objects can be loaded simultaneously giving each frame in the browser it's own object to instantiate and use.
My question is the general usage of the COM server itself. In this project, the COM server EXE is being continually polled for information by the Interface object which uses connection points and available IDispatch interfaces to deliver content to the frame in the web page that's loaded it. In this case, the COM server's methods can be accessed by many different objects simultaneously. The COM server has 2 "data stores" using STL maps. These stores are each protected by their own mutexes and are therefore "safe" from being hit simultaneously. However, do I also need to protect each exposed function call with it's own mutex? I'm a bit new to using a Single Instance object in this way so I'm not sure what kinds of protection I need to include in it... yes, the object's methods are currently unprotected and yes it could very well be called into simultaneously from various interface objects.
Thanks for the help.
Matt
|
|
|
|
|
Must protect only shared memory access "data stores" inside that object.
soptest
|
|
|
|
|
Is there any way to load a COM (in my case an exe) without having to register it? I would like my component to be used in computers with restricted accounts that don't allow registering components.
Is there any other way to do it?
Thank you.
|
|
|
|
|
I could very well be incorrect... but I'll just say no. COM is registry dependent. If you can't use the registry, just make yourself a plain DLL.
|
|
|
|
|
Matt is correct. Remember that COM basically is nothing more than DLLs with published interfaces (through a TLB file) where the COM runtime couples interfaceid to componen't implementation code through the registry. Obviously, I'm over-simplyfying what can be very complex, but the point is that the registry is an integral part of how COM gets from a requested interface id to the server.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
In case of COM inproc server (DLL):
#import "c:\tmp\testobj\debug\testobj.dll"
typedef DWORD (WINAPI _DllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
int main(int argc, char* argv[])
{
::CoInitialize(0);
{
HINSTANCE hi = ::CoLoadLibrary(L"c:\\tmp\\testobj\\debug\\testobj.dll", TRUE);
HRESULT hr;
_DllGetClassObject *f;
f = (_DllGetClassObject*)::GetProcAddress(hi, "DllGetClassObject");
hr = ::GetLastError();
//CLSID of you COM object CLSID_test
CLSID clsid = {0xC795331E,0x0C56,0x11D6,0xA0,0xFD,0x00,0xB0,0xD0,0xC3,0xD9,0xBD};
::IClassFactory *pcf;
::TESTOBJLib::Itest *pObj;
hr = f(clsid,IID_IClassFactory,(void**)&pcf);
if(SUCCEEDED(hr))
{
hr = pcf->CreateInstance(0,__uuidof(::TESTOBJLib::Itest), (void**)&pObj);
pcf->Release();
if(SUCCEEDED(hr))
{
hr = pObj->In("test");
pObj->Release();
}
}
}
::CoUninitialize();
return 0;
}
soptest
|
|
|
|
|
I need to pass a menu from one COM object to another. Is this possible? The menu would be an out parameter, do I need to allocate memory for this? Or can I just pass a HMenu and duplicate (DuplicateHandle (???)) this on the other side?
|
|
|
|
|
idl definition:
[id(11), helpstring("method GetMenu")] HRESULT GetMenu([out] HMENU* pmh);
C++ implementation:
STDMETHODIMP Ctest::GetMenu(HMENU *pmh)
{
if(!pmh) return E_POINTER;
*pmh = m_hMenu;
return S_OK;
}
soptest
|
|
|
|
|
Thanx for answering. But when you pass something as out parameter, the caller is responsible for freeing the allocated memory, so mustn't the server copy the HMENU? If so, how do you do this? There does not seem to be a method for copying HMENU's.
|
|
|
|
|
HMENU is DWORD, so
in application:
HMENU rhm = 0;
pObj->GetMenu(&rhm);
if(rhm)
{
//rhm now has value
}
soptest
|
|
|
|
|
Hi All,
I was trying to write a connection point console client using c++ and ATL.
Can any body give me some pointers in this. I dont want to use MFC.
Thanks in Advance
Anil.S
|
|
|
|
|
I'm accustomed to using COM in one of two ways:
- As a client when I need to call into an interface for a given method to perform a specific task
- As a component that performs a finite task
However, with the COM+ Loosely Coupled Events I'm confused about how a particular scenario would play out. Let's say I have a CodeProject like application where I want certain subsystems to be alerted any time a new article has been added to the system. Therefore, ...
- I create an ATL project (NewArticle) and add an ATL component to it with an interface called INewArticleEvent and a method called NewArticle.
- I create a new COM+ application (NewArticleApp) and add the INewArticleEvent component as an event class.
- I create another ATL project (LatestUpates) and add an ATL component to it and implement the INewArticleEvent interface.
- For this second component, I create a new COM+ application (LatestUpdatesApp) and add the component as a regular class (as opposed to an event class).
- I add a subscription to the component and specify the INewArticle.NewArticle interface.
- Now when I write code to fire the NewArticle event, the subscribing component in my LatestUpdates component is called as it should be by COM+.
So, it's all good, right? However, here's my question. What if I want to update a currently GUI as a result of an event having been fired? I have this LatestUpdates component that's getting called. But, how can I somehow tie that to my MFC application so that I now list the new article on it's form view?
I'm sure this is COM+ 101, but I'm at a loss.
Thanks for anyone that can help me!!!
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|