|
What about your IDL definition?
If you don't mind, show your idl definition.
MIDL compiler don't generate type library without proper keywords.
Regards,
Ryan
|
|
|
|
|
Thanks for your concern, but I asked the author of those VB components to recompile his works.
Don't understand why, but after recompilation, I could view all the IDL's with OLE Viewer and #import them without any problems.
As long as it works - I am happy.
|
|
|
|
|
I have a DLL component with some User Interface sitting on my server machine. My test program is on the client machine. I want my test program to activate the DLL component on the server machine. But I want the UI to be visible on the client machine.
Anyone knows how to do it?
Thanks a lot!
|
|
|
|
|
Hi,
I use a COM object(lot of classes and functions) that does not support the multi thread call.
The program i do is multithread and then i have problem with the COM object.
i would like to serialize all the calls i have to do to this object in a single thread. From the creation of the object to its release.
Can someone help me please?
thanks!
|
|
|
|
|
If you are using ATL, try to use CComCriticalSection object. Create the data member of that type in your class and initialize it in your object's constructor. Use CComCriticalSection::Lock() and Use CComCriticalSection::Unlock() methods in code blocks that require only-one-at-a-time execution (a.k.a. serialized access or thread-safe code). This object is well documented in MSDN library. The alternative to it is Win32 API:
CRITICAL_SECTION hMyCS;
InitializeCriticalSection(&hMyCS);
***
***
EnterCriticalSection(&hMyCS);
// your thread-safe code begings
***
***
***
// your thread-safe code ends
LeaveCriticalSection(&hMyCS);
As opposed to events, semaphores, and mutexes, critcal sections are the easiest and fastest synchronization objects.
Second, events, semaphores and mutexes are mostly used for inter-process syncrhonization and communication, but you still can use them at intra-process level.
When Critical Sections are used, all client threads that access your component will be automatically queued in First-Come-First-Served fashion. Windows and COM runtime will take care of that for you.
Hope you find it helpful.
Kirill Sherman
shermank@glstrat.com
|
|
|
|
|
All right for that,
but even if the threads are queued in critical section, the critical sections are accessed by several threads, not at the same time sure!
I have a class:
Class CObj: public COleDispatchDriver{
public:
LPDISPATCH fct1(COleVariant vrIndex);
short fct2();
};
what i want is that a thread controls the access to fct1 and fct2 as a consequence, only this thread will use these functions!
even if other threads call them, i want to execute these functions always in the same thread!
In fact, it's a problem that i have with an ActiveX i use, its threading model is appartment, but sometime, when i access classes of the activeX with different threads, i have an error (the error is done by the activeX i use, not a window exception). Then, i thought that the best way was to create a wrapper class to the ActiveX, and this wrapper class will always work in one thread. So, all calls to the activeX are serialized.
Thanks!
|
|
|
|
|
That's where COM apartment may help. Your ActiveX control is apartment threaded, which means that all calls to that object always must be executed on the same thread. Looks like your client also apartment threaded, but probably when you use your ActiveX object on other thread you didn't marhsall you interface pointer (CoMarshalInterface or CoMarshalInterThread..).
One possible fix, that won't require much changes, is to put all client threads in free threaded apartment (each thread should calls CoInitialiseEx(NULL, COINIT_MULTITHREADED)). There will be slight perfomance hit, since all the calls to your object will be marshalled. If it's not acceptable ( or the client must be apartment threaded), than you'll need to use CoMarshal../Unmarshall or Global interface table (see IGlobalInterfaceTable, CLSID_StdGlobalInterfaceTable) to marshal interface pointer between apartments. In this case the calls from apartment that created object won't be marshalled.
Hope this helps.
Edward.
|
|
|
|
|
How do you position a chart that was add from excel to the second page. I used the AddOleObject method and i did not specify an anchor. Does anyone know how to set up an anchor?? Any help will be appreciated.
DrunkerII
|
|
|
|
|
I define this struct in my IDL:
typedef struct PATIENT_INFO
{
[string] wchar_t wszLastName[ 50 ];
[string] wchar_t wszPatientID[ 30 ];
} PATIENT_INFO;
When I compile I get this error:
midl\oleaut32.dll : error MIDL2020 : error generating type library : LayOut failed on struct : __MIDL___MIDL_itf_PatientTestSvr_0000_0001
When I take out the [string] attribute it compiles fine.
It is my understanding that the [string] attribute means only the NULL terminated string itself will get marshalled and not the whole buffer (which is the behavior I want).
Is my understanding correct and how can I get this to compile?
Glenn Wardius
GE Medical Systems
|
|
|
|
|
first rid yourself of the [50]'s cause you don't need them. the string attribute tells MIDL to look for the null terminator and it does size calculations on its own. Next get rid of the typedef. MIDL doesn't need it. just use
<br />
struct PATIENT_INFO<br />
{<br />
[string] wchar_t wszPatientID;<br />
[string] wchar_t wszLastName;<br />
};<br />
Hope this helps ya out.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
I am using automation to open an Access 97 database, and run a report. It works fine as long as I'm not trying to use a WHERE clause.
For example, this code works fine:
void CAccessReports::RunReport(CString strReportName)
{
if (m_pAccess && m_pDoCmd)
{
m_pDoCmd->OpenReport(
COleVariant(strReportName),
2, // acViewPreview
COleVariant(),
COleVariant());
m_pAccess->SetVisible(TRUE);
}
}
but this code:
void CAccessReports::RunReport2(CString strReportName,CString dfilter)
{
if (m_pAccess && m_pDoCmd)
{
m_pDoCmd->OpenReport(
COleVariant(strReportName),
2, // acViewPreview
COleVariant(),
COleVariant(dfilter);
m_pAccess->SetVisible(TRUE);
}
}
blows up with an Access error:
"Data type mismatch in criteria expression.@@@2@5003464@2"
(My WHERE clause is: [StartDate]>='04/02/2001' and [EndDate]<='04/18/2001')
What am I doing wrong here?
Thanks in advance for any help!
|
|
|
|
|
Hi all,
I am trying to pass BSTR arguments to a component's function from a client !I am using L prefix for the arguments !The problem is I am not getting any argument value in the function at the component !What may be the problem !
How can i successfully pass the BSTR arguments to the Interface function !
Thanx in advance for the help !
Y.Yamini Devi
|
|
|
|
|
Using L before a string makes it Unicode, not a BSTR. Read up on SysAllocString() and related APIs, and the _bstr_t CComBSTR wrapper classes.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi Yamini
The component u r using in VC++, i suppose have u tried L"xyz" in this fashion.if not then try it,possibly u will get the answer.Or try in this way:-
CString str;
str="ABC";
str.SysAllocString();
This may solve the problem.
Bye
|
|
|
|
|
Hi Yamini
The component u r using in VC++, i suppose have u tried L"xyz" in this fashion.if not then try it,possibly u will get the answer.Or try in this way:-
CString str;
str="ABC";
str.SysAllocString();
Then pass this instead of BSTR argument.
This may solve the problem.
Bye
|
|
|
|
|
How do I return an array of strings in IDL and COM? E.g. I would like a function that does something like this:
struct StringListType
{
long m_lNumStrings;
[string, size_is(lNumStrings)] wchar_t ** pStrings; // Is this correct???
};
void GetStrings( [out] struct StringListType * pStringList )
{
wchar_t Str1[] = "A silly string!";
wchar_t Str2[] = "You're da bomb ";
// What goes here to put Str1 and Str2 into pStringList???
}
I know I have to do some TaskMemAlloc() but am not sure of the correct way to do it. Also, I'm not sure of the proper way to specify an array of strings in the IDL above.
Thanxs for any help!
|
|
|
|
|
Hi everyone,
I don't know how to use two filtergraphs simultaneously in my application. When I
build two identical filtergraphs to capture two video sources simultaneously, it
works fine when the two filtergraphs run at the same time. But at the time when I
stop them, the application cracks. Each of the filtergraphs can run and stop
properly if the other is stopped.
Does anyone have the same experience as mine? Please help me solve this puzzle
thanks.
|
|
|
|
|
I'm used to using #import on a type library or the DLL itself and using that to set up my smart pointer to the interface(s) I need.
I'm now writing a COM object that wrappers a COM object written in JAVA. I've never even looked at Java before so what I was given is a series of *.class files which are apparently the equivalent of Java "exectuables" of a sort.
At any rate, I know the ProgID and CLSID of the COM object and can look at it under the OLE viewer. What's the correct way to load an interface to this COM object without having a DLL or TLB to import?
Thanks,
Matt Philmon
|
|
|
|
|
I'm used to using #import on a type library or the DLL itself and using that to set up my smart pointer to the interface(s) I need.
I'm now writing a COM object that wrappers a COM object written in JAVA. I've never even looked at Java before so what I was given is a series of *.class files which are apparently the equivalent of Java "exectuables" of a sort.
At any rate, I know the ProgID and CLSID of the COM object and can look at it under the OLE viewer. What's the correct way to load an interface to this COM object without having a DLL or TLB to import?
Thanks,
Matt Philmon
|
|
|
|
|
what is COM????
thanks for any help...
|
|
|
|
|
|
When I install my control from a CAB file I need to add a registry value as
well as download and register my .dll. None of the reg values reference in
the AddReg statements in my INF file are getting added.
If I extract the INF file manually and right-click Install on the INF
file in Windows Explorer the registry
value is added so I know the syntax of the INF file is correct. I can't use
binary code to simply add the necessary registry values because the people
who are deploying this control need to be able to change the reg values in
the INF to suit their needs and repackage the CAB file. Any ideas of how I
can do this would really be helpful.
Thanks,
Phil
|
|
|
|
|
I am trying to write an out of process com server that is capable of passing back to the client over the network a _ConnectionPtr. It is really a simple 2-tier application. But although the pointer I am getting back looks valid I get an error when I try and open a recordset using the connection returned.
Can anybody help.
I can post some sample code if that would help.
Cheers
AndyC
|
|
|
|
|
Hi,
I´m beggining with ATL and I don´t know how powerfull is it, or in which cases is better to use MFC or...
The most important questions that I have, is that if it is easy to use Compound documents with ATL ( like MFC with Compound documents server), so the user can paste one of this docs in MS Word and then pressing double click edit it there directly... ( that pretty things).
I know with MFC is just a wizard option, but with ATL.... ??? How it works, where can I find one example about that ?
Thanks in advance, Bye !
Braulio
|
|
|
|
|
Hi,
I´m beggining with ATL and I don´t know how powerfull is it, or in which cases is better to use MFC or...
The most important questions that I have, is that if it is easy to use Compound documents with ATL ( like MFC with Compound documents server), so the user can paste one of this docs in MS Word and then pressing double click edit it there directly... ( that pretty things).
I know with MFC is just a wizard option, but with ATL.... ??? How it works, where can I find one example about that ?
Thanks in advance, Bye !
Braulio
|
|
|
|