|
search for Drag drop at code project there are good article releated to this, one of the best one is from Micheal Dunn
The World is getting smaller and so are the people.
|
|
|
|
|
Hi..
I have built a dll file using Visual Basic 6.0 and registered it in
Component Services as a Server Component. Because the dll will run
for more than 1 hour (approximately in about 85 minutes). The
component can be called by ASP or EXE (built using VB also).
The problem will come if there is more than one client application
(could be ASP or EXE) call the component at the same time (for
example 2 ASP request and 2 EXE file). Each client application will
need to call the dll file and process the data (either
insert/delete/retrieve records) based on their own data submitted by
the user, so the data for first client application should not be
processed by the second client application.
But after doing the testing, I realized that somehow the first client
will processed the data for second client application. And also
another strange thing is the latest caller will be processed and
finished first. For example, If the component is called by first EXE,
then 2 seconds later there is another call from second EXE. The
second EXE will be processed and finished first, the first EXE will
wait until the second EXE finished to continue the process.
Does anyone have same experience before? Or is this a limitation of
component built using VB? Also what is the advantage of registering the component (dll file) in multiple Application (Package).
Any suggestions will be appreciated.
Thanks,
Andy
|
|
|
|
|
VB6 can only create STA components, and in my opinion is worthless for web development.
Second: something wrong with your design don't you think? When web component takes 85 minutes to complete?
Brian
|
|
|
|
|
Hi..
The web will only shell (asynschronous) a VB component. The web page do not need to wait until the component finished. SO, the web component is just to trigger only.
Does it mean that there is no way to solve the problem because of thread limitation in VB?
|
|
|
|
|
I would like to extract the content and format from a Word document (in MFC/C++ 6.0).
I have been struggling with the examples. I have the "Word2XML" Microsoft example but find it difficult to decode the VB to MFC/C++. Is TOM a solution ? (TOM does not have any examples in the documentation.) Where can I find a example of its use?
|
|
|
|
|
Hi, I've got a question about a com interface that is a bit slow, so I've put it into a worker thread that seems to go ok. The trouble is this interface takes a connection point interface to report events. By the time the thread has terminated, and thus unitializes com for the thread, not all the events have been fired for the com interface. I was wondering what's the best way to get all the events before the thread returns.
Thanks.
Festina, vita breve est!
|
|
|
|
|
I worked it out, the CoInitialize() call was putting the thread in an STA, but there was no Message pump to process messages and so COM sat around waiting for ever. Who says MSDN help can't be useful sometimes?
Festina, vita breve est!
|
|
|
|
|
Hi,
I Have a custom com object which I want to use as a class member for an implemantation of another COM interface.
This is what I have done and the trouble I am having:
I place the COM object (my own one) as a class member in my class that Implements IExtension. (since all my other objects get a reference to the IExtension to see if it is active or not). I have created two functions which preform operations on the Custom COM object.
This is where I come unstuck. I figured I had to QueryInterface to my own implementation of IExtension which has the methods defined. I don't know how to call my custom functions as I get compilation errors saying:
error C2039: 'GetTargetName' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IMyExtension>'
Error executing cl.exe.
I have no idea why this is happening and cannot work out why. If I have defined my extensions and objects as follows....
The only thing I can think of is that I am breaking one of the RULES of COM. I cannot see which one.
Do I have to explicitly define the QI, AddRef, Release methods in my class? From all the example on here... I didn't think I did... here is a reference to an example: http://www.codeproject.com/com/hellocom.asp[^]
your help would be greatly appreciated.
cheers
Bryce
<br />
class ATL_NO_VTABLE CMyExtension : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CMyExtension, &CLSID_MyExtension>,<br />
public ISupportErrorInfo,<br />
public IMyExtension,<br />
public IExtension,<br />
public IExtensionConfig<br />
{<br />
public:<br />
CMyExtension()<br />
{<br />
const CLSID CLSID_TargetLayer = {0x2CEBA738,0x0533,0x4F68,{0xB1,0xC5,0x88,0xB3,0xD9,0x5B,0xA3,0xE3}};<br />
const IID IID_ITargetLayer = {0xD149DEA4,0xBB32,0x4D9A,{0x88,0xC7,0xA2,0x61,0x43,0x7D,0xC8,0xBA}};<br />
<br />
HRESULT hr = CoCreateInstance(CLSID_TargetLayer, NULL, <br />
CLSCTX_INPROC_SERVER,IID_ITargetLayer,<br />
(LPVOID*) &m_ipTargetLayer);<br />
if (SUCCEEDED(hr))<br />
{<br />
}<br />
}<br />
<br />
DECLARE_REGISTRY_RESOURCEID(IDR_MYEXTENSION)<br />
<br />
DECLARE_PROTECT_FINAL_CONSTRUCT()<br />
<br />
BEGIN_COM_MAP(CMyExtension)<br />
COM_INTERFACE_ENTRY(IHistoryExtension)<br />
COM_INTERFACE_ENTRY(ISupportErrorInfo)<br />
COM_INTERFACE_ENTRY(IExtension)<br />
COM_INTERFACE_ENTRY(IExtensionConfig)<br />
END_COM_MAP()<br />
<br />
BEGIN_CATEGORY_MAP(CMyExtension)<br />
IMPLEMENTED_CATEGORY( __uuidof(CATID_MxExtension))<br />
END_CATEGORY_MAP()<br />
<br />
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);<br />
<br />
public:<br />
STDMETHOD(get_Name)(BSTR * extensionName);<br />
<br />
STDMETHOD(Startup)(VARIANT * initializationData);<br />
<br />
STDMETHOD(Shutdown)();<br />
<br />
STDMETHOD(get_ProductName)(BSTR * Name);<br />
STDMETHOD(get_Description)(BSTR * Description);<br />
STDMETHOD(get_State)(esriExtensionState * State);<br />
STDMETHOD(put_State)(esriExtensionState State);<br />
<br />
<br />
HRESULT SetTargetName(BSTR Name);<br />
HRESULT GetTargetName(BSTR *Name);<br />
<br />
private:<br />
esriExtensionState m_ExtensionState;<br />
IApplicationPtr m_ipApp;<br />
BSTR m_szTargetLayer;<br />
ITargetLayer *m_ipTargetLayer;
};<br />
<br />
<br />
<br />
<br />
<br />
HRESULT CMyExtension::SetTargetName(BSTR Name)<br />
{<br />
return this->m_ipTargetLayer->PutTargetLayerName(Name);<br />
}<br />
<br />
HRESULT CMyExtension::GetTargetName(BSTR *Name)<br />
{<br />
BSTR tmp;<br />
HRESULT hr = this->m_ipTargetLayer->GetTargetLayerName(&tmp);<br />
if(SUCCEEDED(hr)){<br />
*Name = tmp;<br />
return S_OK;<br />
}<br />
<br />
return E_FAIL;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
STDMETHODIMP CMyCommand::get_Enabled(VARIANT_BOOL * Enabled)<br />
{<br />
if (Enabled == NULL)<br />
return E_POINTER;<br />
<br />
HRESULT hr;<br />
long selectionCount;<br />
IExtensionPtr pExtension;<br />
IExtensionConfigPtr pExtConfig;<br />
esriExtensionState state;<br />
<br />
hr =this->m_ipMxDoc->get_FocusMap(&(this->m_ipMap));<br />
if(FAILED(hr)){return hr;}<br />
hr = this->m_ipMap->get_SelectionCount(&selectionCount);<br />
if(FAILED(hr)){return hr;}<br />
<br />
hr = this->m_ipApp->FindExtensionByName(::SysAllocString(L"My Extension"), &pExtension);<br />
if(FAILED(hr)){return hr;}<br />
<br />
pExtConfig = pExtension;<br />
pExtConfig->get_State(&state);<br />
if(FAILED(hr)){return hr;}<br />
<br />
<br />
CComPtr<IMyExtension> pHistExt;<br />
const CLSID CLISID_MyExtension = {0x442A8EAF,0x8723,0x4FED,{0xA8,0xA9,0x6D,0x2B,0x65,0x77,0x26,0x61}};<br />
hr = pExtension->QueryInterface(CLISID_MyExtension, (void **)&pHistExt);<br />
<br />
CComBSTR szTName;<br />
<br />
hr = pHistExt->GetTargetName(&szTName);
if(FAILED(hr)){return hr;}<br />
<br />
<br />
<br />
esriEditState pState;<br />
hr = this->m_ipEditor->get_EditState(&pState);<br />
if(FAILED(hr)){return hr;}<br />
<br />
if(selectionCount>0 && (state == esriESEnabled) && (pState == esriStateEditing) ){<br />
*Enabled = VARIANT_TRUE;<br />
}else{<br />
*Enabled = VARIANT_FALSE;<br />
}<br />
<br />
return S_OK;<br />
}<br />
|
|
|
|
|
I am attempting to pass in an empty collection object (MerchandiseCol) defined in VB to a C++ dll. Once C++ recieves the object, I want to fill it with records from a database, and then return it to the VB executable.
Here is what I have...
<br />
extern "C" void __stdcall GetMerchandiseCol(IDispatch* pMerchandiseCol)<br />
{<br />
HRESULT hr = CoInitialize(0);<br />
if (SUCCEEDED(hr))<br />
{<br />
dbMerch dbM;
_clsMerchandise* pMerch;
_colMerchs* pMerchCol;
<br />
hr = pMerchandiseCol->QueryInterface(__uuidof(_colMerchs), (void **) &pMerchCol);<br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
if(dbM.Open())<br />
{<br />
VARIANT varItem;<br />
CComPtr<IUnknown> pUnk;<br />
CComPtr<IUnknown> pMerchandise;<br />
CComQIPtr<IEnumVARIANT, &IID_IEnumVARIANT> pNewEnum;<br />
if (SUCCEEDED(pMerchCol->get_NewEnum(&pUnk)) && pUnk != NULL)<br />
{<br />
pNewEnum = pUnk;<br />
hr = pNewEnum->QueryInterface(__uuidof(_clsMerchandise), (void **) &pMerch); <br />
<br />
_NoAddRefReleaseOnCComPtr<T>* operator->() const<br />
{<br />
ATLASSERT(p!=NULL);<br />
return (_NoAddRefReleaseOnCComPtr<T>*)p;<br />
}<br />
<br />
|
|
|
|
|
Hi all,
I am facing a strange situation where I am supposed to use an idl which has constants and import it into multiple files. The scenario is like this:
// AAA.idl
module XXXX
{
const DWORD JUNK_1 = 0x20;
...............................................
}
// My1.idl
import AAA.idl;
...........
// My2.idl
import AAA.idl;
As shown above, I need to import the AAA.idl into multiple IDL files and since constants cannot be defined in multiple cpp files within the same project, I am getting "already defined" linker errors (LNK 2001). I cannot avoid importing the AAA.idl into multiple files since I need other interfaces defined within the AAA.idl in several places, how can I overcome this error of redefinitions?
Another point to note is that the AAA.idl file is supplied by someone else, so I cannot modify before using it since it will be a continuous maintenance nightmare. I am mainly looking for options such as ignoring the module XXXX while importing the AAA.idl.
Any help to solve this problem is very much appreciated.
Thanks in advance,
Srikanth
|
|
|
|
|
Hi
I'm creating COM addin for MS Word. I would like to create Option Window for my application, so I used template class CAxDialogImpl(sugested on this message board)
class CDial : public CAxDialogImpl<cdial>
I would also like to set(insert) some properties from Edit Box.
From MFC I found that Edit Box is attached to CEdit class and value can be read into CString class.
Unfortunately when I include CEdit class (or CString) in my declaration of CDial class I get next error:
error C2146: syntax error : missing ';' before identifier 'm_edi'
error C2501: 'CEdit' : missing storage-class or type specifiers
error C2501: 'm_edi' : missing storage-class or type specifiers
so I added: #include <afxwin.h>
but then I get
VC98\MFC\INCLUDE\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
I tried also with settings->General: Use MFC in shared dll
but no success.
Please help
Tomaz Rotovnik
|
|
|
|
|
Hi again
I move #include <afxwin.h>
in file StdAfx.h
but now I get linking error
link: executing 'C:\PROGRA~1\MICROS~4\VC98\Bin\link.exe'
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in RecToR.obj
nafxcw.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in RecToR.obj; second definition ignored
Creating library ReleaseMinDependency/RecToR.lib and object ReleaseMinDependency/RecToR.exp
ReleaseMinDependency/RecToR.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
How can I solve that?
Tomaz Rotovnik
|
|
|
|
|
I think I found the problem.
I write down steps for those who will have the same problem
1. Because dll which I build is Extension DLL I shouldn't have definition _USRDLL in preprocessor definitions
2. I include CEdit, CString classes which need afxwin.h header
so I put #include <afxwin.h> as first include statement in StdAfx.h header file before all other #include statements. (solved C1189 error)
3. I think CDialog class is MFC so I also set option:
Use MFC in a Shared Dll
Tomaz Rotovnik
|
|
|
|
|
Hi, I am having an issue trying to post data using the serverxmlhttp interface. Here is a brief overview:
I am collecting data and automatically sending this data back to central repository. Currently, ftp and smtp protocols perform as expected. HTTP is another story. I have a microsoft service running that kicks of the 'transmitter' when there is enough data to send. That service is running with an administrator account (not THE administrator, but a created user with administrative privaledges.) Anyway, when this service kicks off and creates the COM component that actually does the transmissions, my http transmission portion returns a "Access denied" error. If I run the COM component from an executable, however, the transmission succeeds.
I thought that this was an inheritable rights type problem dealing with the service, however, I have redesigned the system and am now having a server component create and launch the COM transmitter. I still am having the same issue.
Any help would be greatly appreciated. Thanks
|
|
|
|
|
:(Well, sorry to disturb for what surely is an easy thing, but...
Which function must i call if the COM library i want to use defines an interface but no class ?
IID_TheClass is defined, but there is no
CLSID_TheClass, that any tutorial/example/help file i read is using ?
I just can't call CoCreateInstance(Ex)...
Note: i'm trying to use within C++ the Microsoft Euro Converter, that is
----------------------------------------
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: MSOEURO.DLL
[
uuid(76F6F3F5-9937-11D2-93BB-00105A994D2C),
version(1.0),
helpstring("Microsoft Office Euro Converter Object Library")
]
library MsoEuro
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface Converter;
[
odl,
uuid(76F6F3F4-9937-11D2-93BB-00105A994D2C),
dual,
oleautomation
]
interface Converter : IDispatch {
[id(0x00000001), propget]
HRESULT Convert(
[in] double Value,
[in] BSTR CurrencyFrom,
[in] BSTR CurrencyTo,
[in, optional] VARIANT FullPrecision,
[in, optional] VARIANT TriangulationPrecision,
[out, retval] double* retval);
[id(0x00000002), propget]
HRESULT Version([out, retval] BSTR* retval);
};
};
am i lost ?
... yeah
|
|
|
|
|
You can look it up in the registry
Searching for msoeuro.dll under HKEY_CLASSES_ROOT gives us the CLSID {30A095E2-9A0C-11D2-93BB-00105A994D2C} and the ProgID MsoEuro.Converter.1 (data from Office 2000 SP3).
|
|
|
|
|
Woah !
Tricky.
But it works. Thanks !
(just need to find WHAT are the args, now)
-----------
"Always give me a new challenge to take up!"
|
|
|
|
|
Hello everyone. I need some help in writing a very simple OutProc multithreaded server in windows API only (not using any ATL wizard or sth.). I just finished normal singlethreaded component and figured out that I need multithreading support. I have no idea how to "enable" multihreading using my code written before. Does anyone know where can I find any materials or sample projects on this topic? Thanks in advance for your help!!
Greetings - TroLoo
|
|
|
|
|
Check out MSDN for examples. Also Search Google. I recommend these books on COM.
Inside COM (Programming Series) by Dale Rogerson
Developer's Workshop to COM and ATL 3.0 by Andrew Troelsen
Kuphryn
|
|
|
|
|
Does anyone know if neutral threading model doesn't work in in XP?
I seem to be getting different results depending on if I am in XP or windows 2000.
any hints?
|
|
|
|
|
Hi all, how can i change the dllhost appbase to look for assemblies in more directories than %system%\system32 and COM+ root directory.
Thanks.
|
|
|
|
|
I want to change a program id for a com project, so it will be different with the previous version.
Just change the .rgs file? or I need to change the uuid in idl files?
thanks
woody
|
|
|
|
|
Do you mean the prog ID string (eg MyServer.MyObject.1) or the CLSID ? If the latter, then you need to edit both. If the former, I think just the RGS, but I would change both anyway to avoid confusion.
Steve S
|
|
|
|
|
How do you configure a COM method and property so they have the same name? Specifically, we're building a browser application that extends the scripting world and needs to support the syntax:
window.external.Foo.setValue1("fred")
AND
window.external.Foo().setValue1("fred")
NOTE: For the record, if we controlled the JScript and could change it to conform to a single syntax we would.
The client has a bunch of JScript pages they don't control and an existing browser based application that needs to be replaced new application. They don't have access to the original developers or source code.
Thank you.
|
|
|
|
|
Looks like the JScript use the different flags of IDispatch::Invoke function in your cases.
/* Flags for IDispatch::Invoke */
#define DISPATCH_METHOD 0x1
#define DISPATCH_PROPERTYGET 0x2
#define DISPATCH_PROPERTYPUT 0x4
#define DISPATCH_PROPERTYPUTREF 0x8
The JScript uses the DISPATCH_PROPERTYGET flag in first case (window.external.Foo), and the DISPATCH_METHOD in second one (window.external.Foo()). For example, VBScript doesn't separate these cases and uses the DISPATCH_METHOD | DISPATCH_PROPERTYGET flag (which is valid).
As a rule, the default implementation of IDispatch will launch the existing function (either method or propget) in case of DISPATCH_METHOD|DISPATCH_PROPERTYGET. But it call only required function in case of DISPATCH_METHOD or DISPATCH_PROPERTYGET.
So the solution is the changing the passed flags from DISPATCH_METHOD or DISPATCH_PROPERTYGET into DISPATCH_METHOD | DISPATCH_PROPERTYGET and the calling of default Invoke-handler. Because the [propget] member and the [method] member with [retval] parameter are very similar.
HTH
With best wishes,
Vita
|
|
|
|
|