How to solve this question?

Hello all:
      I write a component using ATL and it includes two interface:ISMath and
IAMath,
and now I write client codes and want to the file tlb,Look:
#import "Com_01.tlb" no_namespace
#include <windows.h>
#include <iostream.h>

void main()
{
   HRESULT hr;
   hr=CoInitialize(NULL);
    if(FAILED(hr))
 {
  cout<<"Initialize COM failed"<<endl;
        return;
 }

   ISMathPtr spSFun;
   IAMathPtr spAFun;
   spSFun.CreateInstance(L"Com_01.SMath");
   long  s=spSFun->Add(11,12);
   cout<<s<<endl;
   spSFun.QueryInterface(IID_IAMath,spAFun);//It displays this sentence is
error
   s=spAFun->Sub(22,11);
   cout<<s<<endl;
   spSFun.Release();
   spAFun.Release();
   CoUninitialize();
}
I compile and it displays: 'IID_IAMath' : undeclared identifier,why?how to
do?
Thanks very much.


0
fbjlt (155)
4/9/2007 12:04:17 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
617 Views

Similar Articles

[PageSpeed] 48

On Apr 9, 8:04 am, "Lee Tow" <f...@pub3.fz.fj.cn> wrote:
> Hello all:
>       I write a component using ATL and it includes two interface:ISMath and
> IAMath,
> and now I write client codes and want to the file tlb,Look:
> #import "Com_01.tlb" no_namespace
> #include <windows.h>
> #include <iostream.h>
>
> void main()
> {
>    HRESULT hr;
>    hr=CoInitialize(NULL);
>     if(FAILED(hr))
>  {
>   cout<<"Initialize COM failed"<<endl;
>         return;
>  }
>
>    ISMathPtr spSFun;
>    IAMathPtr spAFun;
>    spSFun.CreateInstance(L"Com_01.SMath");
>    long  s=spSFun->Add(11,12);
>    cout<<s<<endl;
>    spSFun.QueryInterface(IID_IAMath,spAFun);//It displays this sentence is
> error
>    s=spAFun->Sub(22,11);
>    cout<<s<<endl;
>    spSFun.Release();
>    spAFun.Release();
>    CoUninitialize();}
>
> I compile and it displays: 'IID_IAMath' : undeclared identifier,why?how to
> do?
> Thanks very much.


Looks like this interface is not included in .tlh/.tli files. Check
those generated files for this interface. Also, post his in a ATL
newsgroup for suitable responses.

---
Ajay

0
ajaykalra (6842)
4/9/2007 7:14:32 PM
Reply:

Similar Artilces:

SQL Query Question 07-24-07
I have a datbase with 5,000,000 records. I need to work with records 1,000,000 to 2,000,000. I see that Access assigned unique ID's to each record. Can I use this to filter for the data I need ? If so how would I do that ? Thank you in advance. In order to do this, you need a subquery to get the first 2 million records, then you order them in descending order and select the top million records from that recordset. Try something like: SELECT Top 1000000 T.* FROM (SELECT TOP 2000000 * FROM yourTable ORDER BY ID ASC) as T ORDER BY T.ID DESC -- Email address i...

Question of Unicode programming
The exercise code is: int _tmain(int argc, _TCHAR* argv[]) { TCHAR hello[] = "??";//Question 1 TCHAR a[] = { '\u0001', '\u0088', '\u0089', '\u00FF' };//Question 2 wcout << hello << endl;//Question 3 return 0; } Question 1: These Chinese words are copy and pasted from a web page. When trying to save the source code file, the IDE keeps reminding that Unicode can not be saved. How to save Unicode string of "hello"? Question 2: What is the relation between Unicode string like "??" and string like '\u...

Questions on PocketPC and also repositories
I was thinking of switching to Money from Quicken, but have some questions that I hope someone can answer: 1) Does the PocketPC version come with Money 2004 Premium? 2) I have a laptop as well as a desktop. I would like to be able to have Money on both of them. Is there a "repository" where my profile can be stored so that I can enter info into both the laptop and the desktop, and my information remains current? Thanks. Joshua yes, the ppc version comes with the desktop. I'm not totally clear on your second question, but my guess is no. You can share a datafile over a n...

A question about Regular Expressions
Hi all, Does anyone know whether there are similar functions with regular expressions in MFC or STL, just like Pattern and Matcher class in Java 1.4? Thanks! Jason Hello, There are many, do a google groups search as: "regular expression vc" Meanwhile you can look for MS's "GRETA" found at: http://research.microsoft.com/downloads -- Elias http://lgwm.org/ "Jason Zhou" <zwf@eyou.com> wrote in message news:blasc5$3cr$1@bcarh8ab.ca.nortel.com... > Hi all, > > Does anyone know whether there are similar functions with regular > expressions i...

First of a series of questions. 1. Table vs. Questions
Hello All, I'm beginning to build a massive database with more than 10 tables. Currently I have 1 database with 4 tables and 1 query linking certain info from the tables. The query is rather slow when the number of records go over 1000. Is there a way to speed this up when it opens? Which one would you recommend for interactions between tables? Thank you. ...

RSS Feeds question...
Using WLMail v. 14.0.8089.0726 under Win XP sp3 I have a RSS feed (http://www.connectedsw.com/Rss.php?ProductId=57266) that does show on the website (http://www.connectedsw.com/WhatsNew/57266) several updates which I'd like to store in the local copy of the feed but when I use WLMail it only saves the last one. I have added the same feed to Google reader and it did save everything - not just the most current entry. Is this a problem with my computer or something else? Please advise. "Charles Galloway" <CSGalloway@nc.rr.com> wrote in message news:jgr0p5d...

Cash Flow Question #2
I am delving into the cash flow module a bit more deeply this year. It seems that, although I have checked to "pay off balance in full each month", my cash flow does not reflect the payoff. My credit card accounts show a progressively increasing (negative) amount. Is there something I'm doing wrong? Or is this a "feature" with a reason of which I am unaware? I am using advanced budgeting. It does not seem to make any difference if I select to use budgeting or "past trends"; or if I have the credit card accounts listed in the debt reduction planner or not...

Followup question from previous thread IOCTL_EVAL_ACPI_METHOD
Trying to evaluate _TMP method for the thermal zone. My 1st attempt was from user-mode. "Doron Holan [MSFT]" wrote: > you cannot send this IOCTL from user mode, the driver will not process it > I took one more crack at this from a device driver. The code fails in trying to send IRP downstream. The device driver that I am doing this from is a simple support driver that can do writes/reads to/from I/O ports. NtStatus = IoGetDeviceInterfaces((LPGUID)&ThermalGuid , NULL, 0, &list); if (NtStatus == STATUS_SUCCESS) { DbgPrint( "Succe...

Solving an equation in a cell
I have an excel spreadsheet that has a list of numbers that are 55% of a total that is unknown. Is there a way I can create a formula to figure out the total in a cell? Example: 26 - 55% of total My equation is: ..55 * x = 26 I need to solve for x. Is there a way to solve this in a cell? Answered in Worksheet forum. Please don't multipost. -- Andy. "Mark" <anonymous@discussions.microsoft.com> wrote in message news:b62501c43773$454dcd70$a601280a@phx.gbl... > I have an excel spreadsheet that has a list of numbers > that are 55% of a total that is unkn...

Beginners Question
I know how to add two cells but I would like the cells to have a title within the cell. Something like 8.5 Hrs, or 32 steaks. Something like that. -- Thank you in Advance Hi Format>Cells>Number>Custom> #.0 "Hrs" or General "Steaks The part before the text can be formatted in any of the standard number formats. It will appear as 32 Steaks, but all that will be held in the cell is 32, which can then be used in further calculations if required. -- Regards Roger Govier "GordyB" <GordyB@discussions.microsoft.com> wrote in mess...

Calendar Question #3
Does anyone know if you should be able to see appointments in your calendar before accepting them. I have a client who believes this used to work for him and now it does not. After coming back from a week of travelling, he would just go into his calendar and accept meetings from there. Is this possible? Derek Rumig Sorry, connects to an Exchange 2000 server. "Derek Rumig" <derek.rumig@rogers.com> wrote in message news:2tJoc.3301$oq3.18315@newscontent-01.sprint.ca... > Does anyone know if you should be able to see appointments in your calendar > before accepting them....

Question about ISAPI Server Extension
hi, I'm trying to develop something with ISAPI. But so far , I'm not clearly understand on 2 point: 1.How to debug isapi project ? there seems not a effical way to deal with it. 2.I decleared some variants in CTestExtension.How to know whether it's golobal or local? I've tried to declear a member variant like this: private: CString m_Keywords; I find that the value of it is what it is when the last visitor visits . any one can give me some suggestion? many thanks. :) Hi, To debug, go into services in the control panel and shutdown IIS. In VC with your project loaded...

A little question
Using secured version of 'strcpy()' I need to use 'strcpy_s()' version and there lies my problem. In my function I need to copy the result in a char type which is passed to function. I pass a 'char addr[256]' but on my final step function: 'strcpy_s(addr, sizeof(addr), result)' the sizeof operator returns '4' and function chrases. The value of result is lets say an IP address (11 characters). What can I use instead 'sizeof' operater. I cant just use 256 because I use 'myfunction' in few places and passing different kind of char ar...

Team Resource Re assignment question
I am using PS 2007 with SP1 I have a team Team A and Res1 and Res2 are associated with Team A .Res2 acts as a leader. When a Project is published with Team tasks and Task resource is set as Team A. All the tasks are available in Team Tasks page and Res2 self assigns all the tasks to him. Then He click "submit selected" for Project Manager's approval. PM approves it. Then Res2 go to his "My Task" page and try to reassign few tasks to Res1. But Cannot find Res1 in "Reassign To" column. Question. Do we need to have Res1 and Res2 along with ...

Selection.Information Question
Hi all, I am wondering if it is possible to return the table number of the current selection. I have a document that contains a button for creating a new table (formatted in a specific way), each new table contains a activeX control checkbox that if the user clicks they are prompted with a msgbox that asks if they wish to delete part of this new table. Each new ActiveX control is named checkbox1, checkbox2 of course. potentially users could create anywhere up to 200 new tables and without creating a separate sub for each checkbox in anticipation (i.e. document template ...

Problem solved
Hello, at first I want to thank you for the answers. I mentioned in my first posting that I need something like a redirection of messages to another class. I found the solution and made it like this: I call SetWindowLong with the handle to the window that normally receives the messages and gave another fn (a replacement) for the WindowProc (which is located in the other class) to the routine. m_pWndProcOld = (WNDPROC)::SetWindowLong(CCaptionButton::m_hWndCap , GWL_WNDPROC, (DWORD)CCaptionButton::HookedWindowProc) -- regards Thomas cobuser at gmx dot de cobuser at aol dot com --- XCr...

Question (Please)
One of users had a corruption of his profile under W2K3 Enteprise as an Active Directory user who logs on with his Smart Card. I'll call his Domain Name; Bob.Unlucky His profile is; c:\users\Bob.Unlucky When he logged on, he did not get his normal setup (desktop, icons, resolution, etc) and his MS Outlook wasn't setup which was a clear sign of a Profile corruption. I examined his PC and found a new profile; c:\users\TEMP All files in his Documents folder are encrypted using his Smart Card and he could not access any files in; c:\users\Bob.Unlucky\Documents ...

SumIf Question #2
Hi Can anyone tell me if the SumIf function can work with 2 different sets of criteria. eg: A1 = P B1 = M C1 = 20 A2 = P B2 = M C2 = 10 A3 = U B3 = M C2 = 10 I would like a formula to sum the C column numbers based on if the A column returns the letter U and the B column returns the letter M. But return a zero if the A column returns the letter P and the B column returns the letter M. I can get half way there using the SumIf function but I can't get a 2nd criteria in the formula. I run Excel 2000 Any help would be much appreciated =SUMPRODUCT(--(...

split question
Hello I want to split several lines of text in the TXT file "d:\Names.txt" They are seperated with an asterix (*). Like that: one*two three*four five*six seven *eight Please remember the added space after seven and after eight. I want to search for "seven " with a trailing space and replace it with "eight " with a trailing space. I have tried that: Const sNames = "d:\Names.txt" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oNames = oFSO.OpenTextFile(sNames) aNames = Split(oNames.ReadAll, VbCrLf) I tr...

question about using the offset function
Is there a way to use the offset function (or another function) as a way to supply an expanding range to other functions like 'average'? For my purposes, there may be multiple series of numbers within say a column, with each 'series' (i.e. set of contiguous rows) separated by a few blank cells. The objective of the function would be to supply a limited set of numbers (which can expand) to the function whose result is the main interest. For example, within column D, I might have rows 5-10 representing adult male fish weights, rows 15-20 representing adult female fish weights ...

A few questions
Ok, I am starting to understand this monster... a few questions please: 1) I have all the emails (outgoing and incoming) from a certain account in the same folder grouped by conversation - The conversation title is taken from the subject of the first email, right? Can I change the title (name of) the conversation? 2) Is their a way I can have my outgoing messages in this folder have a special Icon (not just the open envelope) 3) Sorry for being picky but the indent space of the thread is to small. Is there a way I can increase the size of the indent? Tahnk Alot RB Raffi Bearmant ...

emails lost with compression error. Restore question.
I run Vista Home Premium and have Windows Home and Student. I use Windows mail. During a mail compression I got an error saying that the program was in use and an error had occurred. All of the e-mails were lost but there was some kind of automatic e-mail restoration. I was able to retreive what I needed from a restore e-mail folder. My question -- There are now a bunch of files in my trash bin relating to the restored e-mails. They showed up there by themselves. When I click on them they are listed as restored Windows Mail files and Recovered File Fragments. Since I have...

2 questions about CreateProcess(...)
Hi, How would I start an application hidden or minimized? PROCESS_INFORMATION pi; STARTUPINFO si; memset( &pi, 0, sizeof(PROCESS_INFORMATION) ); memset(&si, 0, sizeof(STARTUPINFO)); si.cb= sizeof(STARTUPINFO); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW; si.lpDesktop = ""; CreateProcess( NULL, (char*)"C:\\WinNT\\System32\\Calc.exe", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi ); If I add "si.wShowWindow = SW_SHOW;", the application doe...

Question -Problem
Has anybody ever seen an error message (0x800cccF6) message? I cannot configure my Outlook to retrieve Hotmail. Works with other profiles on this computer running winxp. Stan-The-Man-2006 wrote: > Has anybody ever seen an error message (0x800cccF6) message? I cannot > configure my Outlook to retrieve Hotmail. Works with other profiles > on this computer running winxp. If you have a free Hotmail account, note that it won't work anymore (even your other profiles will eventually have problems) - see http://www.slipstick.com/addins/services/online.htm#hotmail ...

how to solve "Non-modal forms cannot be displayed in this host application"
Hi, I am trying to make a modalless form in VB6 that is compiled as an ActiveX DLL. When i use VC6 to instance the activex DLL, my problem appears that "406 Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX control or Property Page." I have my form in modalless style in VB6 and they should be instanced in VC. Does anyone know how to get this to work ? Many Thanks, Xiao http://support.microsoft.com/default.aspx?kbid=176468 -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "arbidol" <arbidol@tom...