473,412 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Header differerences between console app and DLL app with #import

I'm having trouble porting simple MS sample COM code from a console app
to the actual DLL app for my application. The code is pasted in from a
MS sample which was a console app.

The code compiles and executes as desired from a console app.
From a managed DLL app, after adding additional lib files for link, I

can get the code to compile only if I comment out my coclass and
interface definition from the type library.

Code below:

#include "stdafx.h"
#include <iostream>
#include "atlbase.h"
#import "..\Simulator\_Simulator.tlb" no_namespace
using namespace std;
struct OleCom {
OleCom() { CoInitialize(NULL);}
~OleCom() { CoUninitialize(); }
}olecom;
int _tmain(int argc, _TCHAR* argv[])
{
OleCom olecom;
CComPtr<IUnknown> spUnknown;
spUnknown.CoCreateInstance(__uuidof(CCQASimulator) );
CComPtr<ICQASimulator> pI;
spUnknown.QueryInterface(&pI);
short res = 0;
CComBSTR devicefile("c:\\WUtemp\\abc.txt");
CComBSTR logfile ("def");
pI->SimulateDeviceToPC(devicefile.m_str,logfile.m_str );
CUSTOM_DATE date;
date.day = 02;
date.month = 8;
date.year = 1946;
cout << "Day " << date.day << " Month " << date.month << " Year " <<
date.year << endl;
pI->SetDate(&date);
date.year += 2;
pI->SetDate(&date);
CUSTOM_DATE* pDate = NULL;
pDate = pI->GetDate();
date.day = pDate->day;
date.month = pDate->month;
date.year = pDate->year;
cout << "Day " << date.day << " Month " << date.month << " Year " <<
date.year << endl;
::CoTaskMemFree(pDate);
pI->Simulate(STOne);
cout << res << endl;
return 0;
}

Dennis

Feb 22 '06 #1
1 915
I answered my own question,

Those pesky precompiled headers had to be turned off for the files with
native calls in the code.

Feb 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Chris Maloof | last post by:
Hello, Does anyone know how I can read the ASCII text from a console window (from another application) in WinXP? It doesn't sound like a major operation, but although I can find the window via...
0
by: Bryan Olson | last post by:
New and improved! Love Python's stack-tracing error messages, but hate the way GUI applications throw the messages away and crash silently? Here's a module to show Python error messages that...
6
by: metiu | last post by:
Say I have a console app that does something in three steps: - opens a file - transfers the file through a serial port - does some elaborations and I want to build a GUI around it that, for...
4
by: Shil | last post by:
Hi, In VC++.Net 2005 visual studio, if I create a new winform drag and drop a button, then double click it to write click event code, then it auto generates the template code for the event in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.