|
|
Hi all,
I've created a MFC extention dll project. in the stdafx.h file i've wrote:
#undef _GUI_LIB_EXPORT_
#ifdef _EXPORT_GUI_LIB_
#define _GUI_LIB_EXPORT_ __declspec(dllexport)
#else
#define _GUI_LIB_EXPORT_ __declspec(dllimport)
#endif
i have 2 exported classes, 1 is a dialog, the other one is a button:
1) class _GUI_LIB_EXPORT_ CMyDlg : public CDialog
2) class _GUI_LIB_EXPORT_ CMyBtn : public CButton
i use an MFC exe project to test my dll.
in the stdafx.h i also write :
#undef _GUI_LIB_EXPORT_
#ifdef _EXPORT_GUI_LIB_
#define _GUI_LIB_EXPORT_ __declspec(dllexport)
#else
#define _GUI_LIB_EXPORT_ __declspec(dllimport)
#endif
when i compile the exe project (that uses the exported dialog and button classes), it seams to recognize the dialog exported class (CMyDlg) but for the CMyBtn class i get the warning C4273 - inconsistent dll linkage. dllexport assumed.
can any1 help???
i am desparate here..
thanks in advanced,
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
|
warning C4273 - inconsistent dll linkage. dllexport assumed.
Isn't the class to be dllexport is what is you want? So, it is correct then. Unless you are importing functions from DLLs.
Why use the macro? Just put in like this
class __declspec(dllexport) CMyDlg : public CDialog<br />
{<br />
...
why making yourself confuse?
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thanks man!
That did the trick........
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
glad it helps.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
remove the stuff you wrote in the stdafx.h. In your dll project place "_EXPORT_GUI_LIB_" in the preprocessor definitions (project settings). This way the classes will be exported when you have defined "_EXPORT_GUI_LIB_" and imported if not defined (as in your client project). Hope this explains it a bit.
Er zit een korstje op mijn aars.
|
|
|
|
|
Hi,
I have an MFC ActiveX application and on a certain scenario (timing dependent I think) it crashes
with either an "Access Violation" or "Invalid Instruction", and the call stack simply shows:
"GUI! _except_list". I don't get any source file where the crash occured, just some disassembly which doesn't look like valid code (About 100 lines of the same code line in assembly - mov
dword... repreated 100 times or more).
I used BoundsChecker with maxium error checking, but it didn't catch anything.
Any ideas how to catch this?
Thanks.
|
|
|
|
|
Check your *.pdb files. This is where your debugger gets the symbols.(source codes) when debugging.
Hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I found the "except_list" string in my PDB, but it doesn't really tell me anything.
Here's a part of the PDB with the except_list in it.
Every line has an address on the left side, but I didn't add those here.
AfxGetApp@@YGPAVCWinApp@@XZ \q??_7CGUIDlg@@6B@* _numega_finalcheck_Y_110455" 8a??0CStatic@@QAE@XZ* ü]??0CDialog@@QAE@IPAVCWnd@@@Z" g___CxxFrameHandler
__except_list g__EH_prolog& Ô?OnCancel@CGUIDlg@@EAEXXZ" W?OnOK@CGUIDlg@@EAEXXZ" ¾\??3CObject@@SGXPAX@Z" Y??1CGUIDlg@@UAE@XZ2 `#?ReleaseInstance@GUI_MsgMngr@@SAXXZF ‰49?UnregisterMsg@GUI_MsgMngr@@QAEXW4MsgID@@W4ObjectID@@HH@Z2 "#?GetInstance@GUI_MsgMngr@@SAPAV1@XZ" 0__imp__DeleteObject@4>
What can I do with this info?
Thanks.
|
|
|
|
|
You need to have your *.pdb files to be with your *.ocx.
And one more point in case you have forgotten. You need to have your project build in debug mode.
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I think I misunderstood your first post. I thought you meant I need to open my PDB file to check it's contents. I guess you meant to make sure I even have a PDB file.
I do have PDB files for each project, and everything is compiled in debug. On "normal" crashes I do get a normal call stack and can debug normally. On this specific crash the only thing in the stack is: "GUI! __except_list" with no source code.
This only happens on my computer. The same version runs fine on other computers in the company, so it's either something specific which is problematic in my computer, or a specific timing sequence that only happens on my computer and causes it to crash.
Thanks anyways.
|
|
|
|
|
Hi,
Some years ago I had to develop an Windows Service, and it didn't used MFC... now I wonder... it's possible to include MFC on a Windows service ?, How can I do that ?
Thanks in advance, Greetings
Braulio
|
|
|
|
|
Hi,
Create NT Service using ATL COM appwizard.
In StdAfx.h file, include <afx.h> as shown below
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afx.h>
//#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
Now u can use MFC in Service .
Cheers,
Anand
The chosen One
|
|
|
|
|
There is an easy way aswell , User CreateService API , it's takes an Excutable Name and register that as a service .
Atif
|
|
|
|
|
Hello, everyone!
I want to write a console application using VC++ 6.0 to invoke IE to load a html file which
resides on the same path of my application.
My trouble is, I do not know how to locate the executable file of IE, I want to write a
machine independent application and it is impossible to hard code the path of IE in my
program. Maybe I should read from registry or environment variable?
Who can help? Can you give me a sample?
Thanks in advance,
Geo
|
|
|
|
|
CreateProcess will look up the path to the executable, although this isn't that advisable (because an attacker could substitute a different IEXPLORE.EXE earlier in the path).
You might be better off using ShellExecuteEx directly on your HTML file, which will load the program registered to open HTML files.
|
|
|
|
|
Thanks, Mike buddy!
I have make a reference of MSDN of ShellExecuteEx. I have never used this function before, and I find the SHELLEXECUTEINFO Structure is too complicated. So, can you tell me how to fill the value of each fields of this structure in my simple example?
regards,
Geo
|
|
|
|
|
I'd suggest something like:
SHELLEXECUTEINFO sei = { 0 };
sei.cbSize = sizeof( sei );
<font color="green">
sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_FLAG_DDEWAIT;
sei.lpVerb = _T( "open" ); <font color="green">
sei.lpFile = _T( "myfile.htm" );
sei.nShow = SW_SHOWNORMAL; I've used the SEE_MASK_FLAG_NO_UI flag to prevent any message boxes coming up if there's an error. I've also added SEE_MASK_FLAG_DDEWAIT to ensure that launching the file using DDE works - Internet Explorer uses DDE to reuse an existing window if the user has IE configured that way.
You could leave the lpVerb variable set to NULL in order to use the user's default verb (the one in bold when right-clicking an HTML file) but the user could potentially have set this to do something different, rather than Open.
|
|
|
|
|
Thanks, Mike buddy!
I have tried your method in my VC++ 6.0 console application, but there are 5 errors. Here are the source codes:
Source Code:
----------
#include <shellapi.h>
#include <windows.h>
int main (int argc, char** argv)
{
SHELLEXECUTEINFO sei = { 0 };
sei.cbSize = sizeof( sei );
// Add the SEE_MASK_NOCLOSEPROCESS flag
// if you want to wait until the browser is closed
sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_FLAG_DDEWAIT;
sei.lpVerb = _T( "open" ); // Could leave NULL
sei.lpFile = _T( "myfile.htm" );
sei.nShow = SW_SHOWNORMAL;
//ShellExecute(0, "open", "iexplore.exe", "http://www.codeguru.com", "c:\\", SW_SHOWNORMAL);
ShellExecuteEx (&sei);
return 0;
}
----------
Here are the error messages:
----------
c:\program files\microsoft visual studio\vc98\include\shellapi.h(53) : error C2065: 'HDROP' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\shellapi.h(53) : error C2501: 'DECLARE_HANDLE' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : error C2146: syntax error : missing ';' before identifier 'UINT'
c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
LoadHtml.exe - 5 error(s), 0 warning(s)
----------
Can you help?
regards,
Geo
|
|
|
|
|
The documentation doesn't explicitly say so, but shellapi.h has dependencies on the Windows base headers. Include windows.h before any other Windows headers.
|
|
|
|
|
|
Hi!
when I exports a class where I mixed managed and undmaged code and in an another dll try to use the exported class (declared as 'gcroot<cdedusetpdb*> m_SetPDB;' ) I receive the following error when compileing. Why?
I have compiled with option /clr.
DAkut error LNK2020: unresolved token (06000065) CDeDUSetPDB::.ctor
DAkut error LNK2020: unresolved token (06000066) CDeDUSetPDB::Finalize
DAkut error LNK2020: unresolved token (06000067) CDeDUSetPDB::Login
The exported class look like this:
#pragma once
#ifdef IMPL_DPDB
#define CLASS_DECL_DPDB _declspec(dllexport)
#else
#define CLASS_DECL_DPDB _declspec(dllimport)
#endif
#include <afx.h>
#using <mscorlib.dll>
#include <vcclr.h>
#using <system.dll>
#using <system.data.dll> // This is required for the ADO.NET Provider
#using <system.web.services.dll>
#using "c:\Inetpub\wwwroot\DeDUWebService\bin\DeDUWebService.dll"
using namespace System::Runtime::InteropServices;
using namespace System::Web::Services;
using namespace DeDUWebService;
// CDeDUSetPDB
class CLASS_DECL_DPDB CDeDUSetPDB : public CObject
{
// DECLARE_SERIAL(CDeDUSetPDB)
private:
short m_nValue;
public:
// uncomment the lines below to avoid the compiler errors
CDeDUSetPDB() {};
CDeDUSetPDB( const CDeDUSetPDB &s ) // copy ctor
{ m_nValue = s.m_nValue; }
CDeDUSetPDB& operator=( const CDeDUSetPDB &s ) // assignment operator
{ m_nValue = s.m_nValue; return *this; }
// Loggar in på DeDU Databas
int Login(char* szNamn, char* szPwd)
{ return ws->Login(szNamn,szPwd); }
protected:
gcroot<deduservice*> ws;
};
MSc Bertil Morefält
|
|
|
|
|
if you wanted to use a managed object
you will need to declare your class like
__gc class Someclass //to indicate the class is garbage collectable.
hope this helps.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I tried that.
I want to export the hole class so
I declared the class like this
_gc class _declspec(dllexport) Someclass // The compile dosn't allow it.
Why?
MSc Bertil Morefält
|
|
|
|