|
There will be a structure in the code generated by the #import statement that represents the class. You can do __uuidof(that struct) to get its CLSID. Look at the example I have here using Excel:
#import "libid:00020813-0000-0000-C000-000000000046" version("1.6") auto_search no_dual_interfaces rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB") rename("DocumentProperties", "excelDocumentProperties") rename("SearchPath", "excelSearchPath") rename("CopyFile", "excelCopyFile") rename("ReplaceText", "excelReplaceText")
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
{
Excel::_ApplicationPtr xl;
if (SUCCEEDED(xl.CreateInstance(__uuidof(Excel::Application))))
{
}
}
}
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank You very much
But can you please tell me that how to get the IID our we get it in the similar manner.
m_pIDocument.CreateInstance(__uuidof(Excell::IApplication));
|
|
|
|
|
IID? For the interface? That's determined by the interface pointer class you're using to create the instance. In my example, the IID will be the IID of Excel::_ApplicationPtr , which can be accessed using __uuidof(Excel::_ApplicationPtr) , IIRC.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I have done my code this way
hr = CoCreateInstance(__uuidof(CADFilter::NW_Document),
NULL,
CLSCTX_INPROC_SERVER ,
__uuidof(CADFilter::NW_IDocument) ,
(void**)&m_pIDocument );
But the issuse is I am getting a message box getting pooped up while running the application.
And when I comment my change there is no such issue
|
|
|
|
|
deadlyabbas wrote: the issuse is I am getting a message box getting pooped up while running the application.
And when I comment my change there is no such issue
For a start, what does the message box say?
Also - if m_pIDocument is a smart COM pointer which is of interface type NW_IDocument underneath, then this code is more idiomatically correct:
m_pIDocument.CreateInstance(__uuidof(CADFilter::NW_Document), CLSCTX_INPROC_SERVER);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
Following is the code I am trying to do
#import "C:\\Program Files\\BOSS\\SUPPORT\\RealDWG\\cf2407.dll" rename_namespace("CADFilter")
AcRx::AppRetCode acrxEntryPoint (AcRx::AppMsgCode Msg,
void* AppId)
{
// local variables
int cindex;
CADFilter::NW_IDocument *m_pIDocument;
CLSID clsid;
CoInitialize (NULL);
HRESULT hr = CLSIDFromProgID(LPCOLESTR("NW_Document"), &;clsid );
hr = CoCreateInstance( clsid, NULL,CLSCTX_ALL , __uuidof(CADFilter::NW_IDocument) , (void**)&m_pIDocument );
if(SUCCEEDED(hr))
{
AfxMessageBox(_T("Hi"));
}
}But I am getting an " HRESULT hr as an "Invalid class string"
|
|
|
|
|
Probably means "NW_Document" isn't a valid ProgID.
Easiest way to find a class's CLSID given the DLL that contains it is probably to use the OLE-COM Object Viewer. Use the 'View Typelib' command to open the DLL. That'll display an IDL representation of the DLLs type library, including IIDs and CLSIDs.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Dear All,
I have a debug version of vc++ project.
The project result will be called by other program using COM interface.
I use "/embedding" at "Command Arguments" ( MSVC++ 2005).
It works just fine with XP..I can debug the project.
But not with Vista...the loader program will load another instance instead connecting to the one that aleady loaded in memory..
Did I miss some settings ?
Thanks..
|
|
|
|
|
I am writing an out-of-proc COM server. I would like a single instance of my server to handle all clients. This works OK on Vista for clients running at the same privilege level. But if one client is running at normal privileges and another is running as admin, two separate instances of my server will be launched.
Is there any way to allow a single instance of my server handle all clients?
Wayne
|
|
|
|
|
Hi All
I am getting error error when i am useing InvokeHelper.Function
Declreation in Test Header file
VARIANT Get_List(int* SheetName);
And Define in Cpp file of Test
VARIANT Test::Get_List(int* SheetName)
{
VARIANT result;
static BYTE parms[] =
VTS_PI1;
InvokeHelper(0x60030002, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
SheetName);
return result;
}
use Get_List function in main Class FinalDlg like this
Test objXl;
int sCol=3;
objXl.Get_List(&sCol);
Then i am getting
"Type misMatch" in class wincore.cpp.
Plz help me
|
|
|
|
|
"result" variable is uninitialized.
With best wishes,
Vita
|
|
|
|
|
Thanks for reply.
But result variable is initialize here
VARIANT result;
Sorry can you describe more.
|
|
|
|
|
No, this is uninitialized variable. But it doesn't help as I see the code of MFC.
So, I think that VTS_PI1 is unapplicable here. Use VTS_PUI1 or VTS_PI4.
With best wishes,
Vita
|
|
|
|
|
Ok i use
VTS_PUI1 or VTS_PI4. both now error is same.
If you need example code then i will give you.I need help.
|
|
|
|
|
What declaration of method 0x60030002 do you have? What is a "Test objXl"?
With best wishes,
Vita
|
|
|
|
|
See i don't much about InvokeHelper.I had download a project from Codeproject and make new project with the help of downloaded project.I am sending you a project link which have example code and Dll.
Link is here
Automating Microsoft Excel and Word Together[^]
I am creating a new dll and write a new function.
Public Function Get_List(SheetNumber As Long) As String
' Dim myExcel As Object
Dim Counter1 As Integer
Dim Returnstring As String
Dim myWorkBook As Excel.Workbook
Dim tworksheet As Excel.Worksheet
' myExcel = CreateObject("Excel.Application")
' myWorkBook = myExcel.Workbook.Open("C:\sample.xls")
For Each tworksheet In myWorkBook.Worksheets
' Me.ListBox1.Items.Add (tworksheet.Name)
Returnstring = tworksheet.Name
If iindex = Counter1 Then
Get_List = Returnstring
End If
Counter1 = Counter1 + 1
Next
End Function
And try to access in vc++.Then i am getting error
Plz help me
|
|
|
|
|
Sorry, it requires so much time which I don't have.
Try to call the simpler function, for example,
Public Function Get_List(SheetNumber As Long) As String
Get_List = "aaa"
End Function
With best wishes,
Vita
|
|
|
|
|
i am doing something wrong.See I add function in Dll
Public Function Get_List(SheetNumber As Long) As String
Get_List = "aaa"
End Function
And Declaration in m2msofficecom.h file
VARIANT Get_List(long* number);
And Define in m2msofficecom.cpp
VARIANT _clsExcel::Get_List(long* number)
{
VARIANT result;
static BYTE parms[] =
VTS_PI4;
InvokeHelper(0x60030002, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
number);
return result;
}
And Call in MainDlg Class
_clsExcel objXl;
long ty=1;
objXl.Get_List(&ty);
but still i am getting same error.
plz help me.
|
|
|
|
|
I can only propose that 0x60030002 is not Get_List function. You can look at DLL by "Ole/COM Viewer" and find the declaration of _clsExcel interface.
Can you post the direct reference to your DLL?
With best wishes,
Vita
|
|
|
|
|
please explain in detail.i am also think about 0x60030002 is not Get_List function.But how can i find it.
|
|
|
|
|
VB creates the DLL, which has a TLB inside. Run the "OLE/COM Viewer" and File -> View TypeLib....
Perhaps there is a MFC Wizard which also can import this TLB into code. But I don't know about it, because I use #import directive in C++ client code.
With best wishes,
Vita
|
|
|
|
|
ok i am trying to do that.
|
|
|
|
|
Thanks for smart ans..
Problem solved.
|
|
|
|
|
|
Hi All,
I have say re-compressed a jpeg image using my own compression engine. And have added a reference to this image in a html page through the IMG tag. When i access this html file hosted on the web server using HTTP, I need Internet Explorer to call my decompressor when it sees this particular filetype, decompress the image and display the image just as IE would do for any already established filetype such as jpeg.
I have already used MimeFilter for this but the limitation for MimeFilter is that it can be used to Filter file/MimeTypes only when they are the first resource accessed directly through the Href links i.e. the following link "http://myserver//myimg.xxx" (xxx - my extension) when accessed directly by typing in the address bar would fire the MimeFilter and decompress and display the image. But MimeFilter is limited to only this and cannot be used for other resources embedded in the HTML page like the ones in IMG tag.
My question is whether there is a way to display images of custom filetypes embedded in HTML pages using tags (eg: img tag). Any help would be appreciated.
Regards,
Srini
|
|
|
|