|
I have an ATL DLL wriite in VC++....and i usng that DLL in a vb project....the problem is that first the dll was working as desired but not now....so i want debug the code and step into the code of the DLL ....can somebody suggest me a solutions.
Deepak Sharma;)
|
|
|
|
|
Place debug build DLL, run VB host. Go into visualStudio build >start Debug> Attach to process, select host process. Load source code place break point.
|
|
|
|
|
Set Break point in your VC++ code. Goto Project-Settings-Debug - Set Executable for Debug session to VB6.exe. Go.
|
|
|
|
|
What I would like to do is create instance of "MSWC.BrowserType". Something similiar to vanilla Com....
CCOmBSTR ProgID(L"MSWC.BrowserType");
hr = ::CLSIDFromString(ProgID, &clsid);
if( FAILED(hr) )
{
hr = ::CLSIDFromProgID(ProgID, &clsid);
if( FAILED(hr) ) return hr;
}
hr = ::CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IDispatch, (LPVOID *)ppVal);
//At this moment returns 0x80040154
if (SUCCEEDED(hr))
|
|
|
|
|
Scenario: Application0 creates an instance of Application1, which in turn creates an instance of Application2. However, sometimes Application2 does not support the interface Application1 wants to use. The HRESULT returned from CreateInstance() will then indicate "No such interface supported".
How do I (in Application0) find out the name of the interface that caused the error?
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
I'm writing a windowless ActiveX control using MFC & VC 6 to perform background ZModem file xfers for a FoxPro 7 app. I'm using Mark Nelson's ("Serial Communications Developer's Guide") Win32 serial library. For a test mechanism, I run 2 instances of the program on the same computer (simulating a modem connection) with 2 serial ports connected via a null modem cable.
Once the control connects to it's test "modem", each instance of the control starts another background thread so that when no file transfer is taking place, the control periodically checks to see if the other end of the phone line is trying to send a file. I would like to fire events up to the FoxPro client so that the client knows when it's receiving a file, finished receiving a file, an error occured, etc.
Events fired from the main thread of the control work without a problem. As long as I don't fire events from within my secondary thread, everything works fine. A FoxPro client never sees events fired from with the secondary thread; a VB client crashes with an access violation when the secondary thread fires an event.
Does anyone have an idea why this is happening? Any help is appreciated.
|
|
|
|
|
Ya, you meet the monster called Marshalling
It's for longer description, but in short words, VB (not only VB of course) expect that you will fire events in the same thread your component was created. This is because your component is probably marked as using Apartment Thread Model.
In case you need to fire events from the secondary thread, you need to marshall the pointer to the VB event callback interface.
As a starter the
CoMarshalInterThreadInterfaceInStream function might help. Or article in MSDN named In-Process Marshaling Helpers
In short - the CoMarshall... packages the interface to the stream in a first thread, you transfer the stream pointer to second thread and demarshall here - retrievnig the correct callback interface.
If you are sure that your component will not run in some old win95 you can look also for using the GIT (Global Interface Table).
For this I would start in help with IGlobalInterfaceTable documentation.
The difference between is that CoMarshal... is useful only when you need to marshall the interface once. Once you retrieve the interface back, the stream became useless.
GIT allows you marshall once, demarshall more times.
If you have more Q, don't hesitate to ask.
|
|
|
|
|
Thanks. I had an epiphany last night that that's where I should be looking. I don't understand all the details yet, but I will. Thanks again!!!
|
|
|
|
|
I have wrote a COM to wrap around registry api. This code can be compiled but it crashed VB while I calling this method. Because I'm new to C++, I don't know much about its datatype conversion. I think the problem should be in RegOpenKeyEx or RegQueryValueEx calling. Can anybody give me the solution.
STDMETHODIMP CoRegistry::GetKey(BSTR sKeyFolder, BSTR sKeyName, BSTR* sKeyValue) {
USES_CONVERSION;
HKEY hKey;
CComBSTR bstrKeyFolder;
bstrKeyFolder = L"SOFTWARE\\";
bstrKeyFolder.AppendBSTR(sKeyFolder);
LPBYTE pRegData = NULL;
unsigned long* lpLength;
*lpLength = 255;
if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_LOCAL_MACHINE, OLE2T(bstrKeyFolder), 0, KEY_ALL_ACCESS, &hKey)) {
if (ERROR_SUCCESS == RegQueryValueEx(hKey, OLE2T(sKeyName), 0, (unsigned long*)REG_SZ, pRegData, lpLength)) {
*sKeyValue = SysAllocString(L"helo"); //this is just for test
RegCloseKey(hKey);
return S_OK;
} else {
RegCloseKey(hKey);
return S_FALSE;
}
} else {
RegCloseKey (hKey);
return S_FALSE;
}
}
Thanks
|
|
|
|
|
Vorrarit Luengwattanakij wrote:
if (ERROR_SUCCESS == RegQueryValueEx(hKey, OLE2T(sKeyName), 0, (unsigned long*)REG_SZ, pRegData, lpLength)) {
*sKeyValue = SysAllocString(L"helo"); //this is just for test
These are the sources of your problem
1. "(unsigned long*)REG_SZ" translates to memory address of 0x00000001, writing to it will create memory access violation
What you meant to do
DWORD dwType = REG_SZ;
.... RegQueryValueEx(hKey, OLE2T(sKeyName), 0, &dwType .....
2. The following is similar, your assign value to memory though uninitialized pointer
Vorrarit Luengwattanakij wrote:
unsigned long* lpLength;
*lpLength = 255;
Solution is similar as well
DWORD dwSize = 255;
.... RegQueryValueEx(...., &dwSize) .....
3. The buffer you pass should be allocated by you to the size of #2
Vorrarit Luengwattanakij wrote:
LPBYTE pRegData = NULL;
BYTE pRegData[255];
P.S. You really should read something on pointers and memory allocation.
|
|
|
|
|
Thank you very much. Those DWORD, LPBYTE, LPTSTR datatypes made me nervous. When reading about C, C++ books, they mostly teach about char*, int*. I would be grateful, if you can provide some sources of information about them.
|
|
|
|
|
DWORD and others described pretty well in MSDN. The truth is they confuse many people. I am using F12 when I do not know what it stands for; it is very handy feature of VS.
|
|
|
|
|
When I call function from client ,it returns error
0x800706b9(resource is not enough).But after I change position between client and server ,it's ok.Why?
Example:
Server: Windows2000,Visual Studio.NET
Client: Windows2000,Visual Studio 6
It's failed
Server: Windows2000,Visual Studio 6
Client: Windows2000,Visual Studio.NET
It's ok
|
|
|
|
|
Sorry for what may seem like a series of dumb questions.
There is a project my team may be working on and we have not much exposure yet to SOAP. The project will consist of wrapping or chaning the existing DCOM interface to SOAP or some other .Net friendly interface that managed code can use.
Currently, we have methods/functions that get and set data to a remote server and work something like this:
#define RD_MEDIA_TYPE DATA_TAG( RDT_LONG, 0x0301 )
#define RD_SUBMIT_TIME DATA_TAG( RDT_FILETIME, 0x0302 )
#define RD_SUBJECT DATA_TAG( RDT_LPTSTR, 0x0303 )
#define RD_CALLER_ID DATA_TAG( RDT_LPTSTR, 0x0305 )
#define RD_CALLER_NAME DATA_TAG( RDT_LPTSTR, 0x0306 )
#define RD_LENGTH DATA_TAG( RDT_LONG, 0x0307 )
#define RD_IMPORTANCE DATA_TAG( RDT_LONG, 0x0308 )
#define RD_SND_CALLER_NAME DATA_TAG( RDT_FILE, 0x030D )
#define RD_SND_BODY DATA_TAG( RDT_FILE, 0x030E )
#define RD_TXT_BODY DATA_TAG( RDT_FILE, 0x030F )
#define RD_FAX_BODY DATA_TAG( RDT_FILE, 0x0310 )
pHost->GetMessageProps( szID, 8,
RD_MEDIA_TYPE, &lMediaType,
RD_SUBMIT_TIME, &timeSubmit,
RD_CALLER_NAME, &strSender,
RD_CALLER_ID, &strCallerID,
RD_SUBJECT, &strSubject,
RD_IMPORTANCE, &lPrior,
RD_LENGTH, &length,
RD_FAX_BODY, (IBin*) &bin);
We define data tags as many types including binary objects, strings, string arrays, binary arrays, time, bool, long, etc... all with variable lengths. The function takes a paramater (second paramater) to determine the number of properties we are setting or getting. There is no requirement that the properties be in any order, just that the address is the correct data type. The number of properties can be anywhere from 1 to hundreds (well, we only have about 50 defined currently) in one function call.
We also have functions like:
and like:
CStringArray saIDs, saAttns;
m_pHost->GetRoutingInfoByMboxID(szMBox, g_szaType[iType], &saIDs, &saAttns)
Can I easily wrap these functions as methods that managed code could make use of? What would it look like? I am especially interested if anyone has done this type of work before... did you have to rewrite your code or was it easy to wrap your DCOM interface with SOAP type interfaces?
|
|
|
|
|
How do you get the count of the currently executing objects in a COM+ application. I need to track the number of objects currently running as the objects are created and destroyed.
I have been looking at the COM+ Administration Collections, and so far it seems that most of the collections are not for the live objects (objects currently running). Where else should I be looking?
Thanks
Gaul
Gaulles
|
|
|
|
|
Hello All,
I have a validation, replacing quotation mark in my dll as soon as surname or first name has been passed from my form.
The code is : CStr(Replace(Trim(surname), "'", "$0"))
The problem is when I type a surname = "O'Brian" the data does not go to the database and has internal server error.
Can anybody suggest any other way I can liminate this problem?
Many Thanks
Bravo Two Zero
A pen is mighter then a sword.
|
|
|
|
|
Friends Pls help me.
I wants to add the MS paint as Active Document
in my MFC application.
How can I do that
Hemant
|
|
|
|
|
MS Paint lives both as a stand alone app, and as an insertable OLE object. I got its clsid by just starting MSDEV OLEView and then by looking into the OLE 1.0 object hierarchy, where I have found :
-"PaintBrush picture"
-CLSID={0003000A-0000-0000-C000-000000000046}
-localserver32=...\mspaint.exe
-...
|
|
|
|
|
Thanks
but insted of using direct CLSID I used it like this
if(S_OK != CLSIDFromProgID(OLESTR("pBrush"), &dlg.m_io.clsid))
{
return;
}
Is this correct ? Or any problem
|
|
|
|
|
Replace pBrush with Paint.Picture
(it's declared in the registry : HKCR\Paint.Picture)
|
|
|
|
|
I am working with a project which handles large compound files. Now I face a problem with IStream::Write().
IStream::Write()retuns an error STG_E_DOCFILETOOLARGE (Error:"The compound file is too large for the current implementation").
I am trying to write in a compound file created with 512 Byte sectors (Info MSDN see below). The current file size is about 300 MByte and the number of streams are about 100000 ! The error occurs only with Win 2000 SP3 and XP SP1. In Win NT 4.0 SP6a it works !!! When I create the file with 4096 Byte sectors in StgCreateStorageEx, IStream::Write works for Win 2000 and XP too. Now my question: Is this a bug?
Info from MSDN Library:
The compound file implementation can be configured to use 512 or 4096 byte sectors, as defined in the STGOPTIONS structure. File size limits: 512: 2 gigabytes (GB) 4096: Up to file system limits Number of elements in a file: 512: Unlimited, but performance may degrade if elements number in the thousands 4096: Unlimited
Mainul Hossain
Germany
|
|
|
|
|
What implementation of IStream are you using (how do you create stream object)?
|
|
|
|
|
Hello!
I have a COM (ATL) object IDataProvider which used to provide data to some services. This object can be used from other processes.
Also I have a C++ object which contains data and I need to attach this object to IDataProvider object somehow.
eg:
class CDataContainer
{
...
};
class ATL_NO_VTABLE CDataProvider :
public CComObjectRootEx<ccommultithreadmodel>,
public CComCoClass<ctestdataprovider, &clsid_dataprovider="">,
public IDataProvider
{
...
}
I need something like this:
void CDataContainer::DoDataExchange(pDX)
{
CComPtr<idataprovider> pDataProvider;
pDataProvider.CoCreateInstance(CLSID_DataProvider);
pDataProvider->SetDataContainer(this);
// pDX object can be located in another process
pDX->DoDataExchange(pDataProvider);
}
========================================================
IDataProvider object can be created only from DLL which contains CDataContainer code. Can I use it like this:
class CDataContainer
{
...
};
class CDataProvider : public IDataProvider
{
...
}
void CDataContainer::DoDataExchange(pDX)
{
CDataProvider* pDataProvider = new CDataProvider(this);
// pDX object can be located in another process
pDX->DoDataExchange(pDataProvider);
}
With regards,
Pavel Krupets
|
|
|
|
|
It has to be a COM object. Try IDataObject interface.
|
|
|
|
|
Hello!
Thank you for reply.
Do you mean I cannot use "class CDataProvider : public IDataProvider"?
If so I was almost sure it won't do the trick.
But in my case I cannot pass data to server, it have to ask me for it. Because it might use only part of it and it isn't right to load everything.
With regards,
Pavel Krupets
|
|
|
|
|