|
Delphi can not use my lib file so how can I provide dll that I write in vc++ to client that works in Delphi ????
|
|
|
|
|
Is your DLL exporting C style functions or C++ classes?
Michael
|
|
|
|
|
I'm still working through the whole connection point fiasco, with mixed results. OK, I admit it, they aren't mixed, it all blows. I've done a *lot* of reading and at this point I am pretty confident that my connection point is set up properly on the ATL side. I added the IDL manually, like this:
interface ISAFileDB : IDispatch
{
[id(1), helpstring("method Connect")] HRESULT Connect([in] BSTR DatabasePath);
[id(2), helpstring("method CloseDB")] HRESULT CloseDB();
[id(3), helpstring("method ScanDir")] HRESULT ScanDir([in] BSTR dir, [in] BSTR substr, [in] BSTR suffix, [out] IEnumSAFileEntry ** Entered, [out] IEnumSAFileEntry ** Changed, [out] IEnumSAFileEntry ** Skipped);
[id(4), helpstring("method GetDatabase")] HRESULT GetDatabase([out] IEnumSAFileEntry ** Database);
[id(5), helpstring("method SearchDatabase")] HRESULT SearchDatabase([in] BSTR substr, [in] BSTR suffix, [out] IEnumSAFileEntry **Database);
[id(6), helpstring("method DeleteRecords")] HRESULT DeleteRecords([in] BSTR substr, [in] BSTR suffix, [in] BOOL bDelete, [out] IEnumSAFileEntry **Deleted);
[id(7), helpstring("method VerifyDB")] HRESULT VerifyDB([in] BOOL bDelete, [out] IEnumSAFileEntry **Deleted);
[id(8), helpstring("method DoTest")] HRESULT DoTest();
};
[
uuid(224F8579-E559-436C-9FDD-D0CC70E6E013),
version(1.0),
helpstring("SADatabase 1.0 Type Library")
]
interface ISAFileDBEvents : IDispatch
{
[helpstring("method OnTest")] HRESULT OnTest();
};
[
uuid(95B90562-7A7E-4f61-8FE1-D0BB9548294A),
version (1.0),
helpstring("SAFileDBEvents 1.0 Type Library")
]
library SADATABASELib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(2CADF3A1-A5C9-4D89-A8ED-BEA59BDE6857),
helpstring("SAFileDB Class")
]
coclass SAFileDB
{
[default] interface ISAFileDB;
[default, source] interface ISAFileDBEvents;
};
[
uuid(100F3513-A370-434C-AD21-274AF9F3614E),
helpstring("SAFileEntry Class")
]
Then I added a method called DoTest to the ISAFileDB interface, and set up the connection point. I added code for a messagebox to DoTest, and left Fire_DoTest untouched.
Now on the MFC side I set up a class derived from CCmdTarget, like this:
class CConnPt : public CCmdTarget
{
DECLARE_DYNCREATE(CConnPt)
CConnPt();
public:
public:
public:
virtual void OnFinalRelease();
protected:
virtual ~CConnPt();
DECLARE_MESSAGE_MAP()
afx_msg void DoTest();
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
};
and in the .cpp file:
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace, named_guids
IMPLEMENT_DYNCREATE(CConnPt, CCmdTarget)
CConnPt::CConnPt()
{
EnableAutomation();
}
CConnPt::~CConnPt()
{
}
void CConnPt::OnFinalRelease()
{
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(CConnPt, CCmdTarget)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CConnPt, CCmdTarget)
DISP_FUNCTION(CConnPt, "Test", DoTest, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
static const IID IID_IConnPt =
{ 0xc3996b23, 0xcbce, 0x443f, { 0xb5, 0xd8, 0xa9, 0x8a, 0x9d, 0x1b, 0x62, 0xf1 } };
BEGIN_INTERFACE_MAP(CConnPt, CCmdTarget)
INTERFACE_PART(CConnPt, IID_ISAFileDB, Dispatch)
END_INTERFACE_MAP()
void CConnPt::DoTest()
{
AfxMessageBox("sdfsdf");
}
Now I do *this* when a button is pushed in the app
CoInitialize(NULL);
m_pConnPt = new CConnPt();
LPUNKNOWN pUnkSink = m_pConnPt->GetIDispatch(FALSE);
ISAFileDBPtr pIFind(__uuidof(SAFileDB));
IUnknown * pUnk = NULL;
pIFind->QueryInterface(IID_IUnknown, (void**)&pUnk);
AfxConnectionAdvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, &m_dwCookie);
pIFind->DoTest();
AfxConnectionUnadvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, m_dwCookie);
pUnk->Release();
CoUninitialize();
DoTest causes the dialog from the server to come up, but not the one in my CCmdTarget class, instead it crashes in comip.h, in the line:
void _Release() throw()
{
if (m_pInterface != NULL) {
m_pInterface->Release();
}
}
in the Release() call. The disturbing thing is if I trace it back it is the END of my function, when everything is going out of scope, indicating to me that I've got real problems, because by the time it crashes, the time for my connection point to work has well and truly passed.
Can *anyone* see what I am doing wrong and/or provide any advice ? The rest of this project came together like a dream, but the connection points have been an ongoing nightmare...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Christian I mailing you *3* example sof connection points, all pretting darn basic, but illustrates how to implement connection points. The orthodox wat is to use dispinterface, but my examples shows you to use IUknown as well. Also there is an easier why to sink the connection end point again the examples will show you this.
I wrote a shed load of stuff (which I've lost) all about connection points. I'll have a look tonight and mail you if I can find the stuff.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Thanks a ton, Norm. I'll look forward to receiving them.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
CoInitialize(NULL);
m_pConnPt = new CConnPt();
LPUNKNOWN pUnkSink = m_pConnPt->GetIDispatch(FALSE);
ISAFileDBPtr pIFind(__uuidof(SAFileDB));
IUnknown * pUnk = NULL; pIFind->QueryInterface(IID_IUnknown, (void**)&pUnk);
AfxConnectionAdvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, &m_dwCookie);
pIFind->DoTest();
AfxConnectionUnadvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, m_dwCookie);pUnk->Release();
CoUninitialize();
This code has me lost. Why are you asking to be advise of a connection point event and then asking to be unadvised all in the same function? This code doesn't seem like the best way (or even correct way) to use connection points.
Can you explain what your program should do?
Michael
|
|
|
|
|
It's there solely as a test - the DoTest function should fire the connection point event and cause a message box, then I unadvise, because I'm not doing anything except trying to prove I can recieve an event.
Oh, no - it's not a thread issue, is it ? Is one thread trying to fire a CP and the main thread has shut it down ?
Removing the last three lines stops the crash, but my event is still not being called, my message box is not coming up from the MFC side, and tracing into Fire_DoTest() shows that it considers the number of active connections to be 0.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
It's been a while since I've used ConnectionPoints, tend to roll my own now but...
Does the AfxConnectionAdvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, &m_dwCookie) return TRUE?
What if you change the bRefCount parameter to TRUE on the call to AfxConnectionAdvise?
Michael
|
|
|
|
|
You're absolutely right - it returns false, regardless of what I set that parameter to.
GetLastError tells me 'The Handle Is Invalid'.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I can't see anything wrong with the code. I think you need to put some error checking on the code prior to the advise. A few try and catch and checking returning values. Something is failing somewhere (obviously), but without being able to step through the code I can't suggest anything else at the moment.
Michael
|
|
|
|
|
Hi,
I know the name of the application i need to invoke say XYZ.exe I've been using create process giving it the full path of where the exucutable is located. Can Anyone help me out in Invoking this Exe (XYZ.exe) even if it is not in the current path. ie it resides somewhere in the "System PAth" I Have to get the Path of the executable. I've been looking at FindExecutable and AssocQueryString but i'm unable to understand them fully. i'd be very grateful if you could help me out
|
|
|
|
|
PROCESS_INFORMATION pi;
STARTUPINFO si;
// If your app need addiotional parameters, pass NULL in lpAppName and
// fill the lpCommandLine with full path name, and paramateres
// Else, fill the lpAppName with the full path name, and NULL in
// lpCommandLine
// With parameters
LPCTSTR lpAppName = NULL; // name of executable module
// If long path name used, you must double quoted the string
LPTSTR lpCommandLine = "\"C:\Program Files\MyApp.exe\" -L -S";
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
CreateProcess(
lpAppName, // name of executable module
lpCommandLine, // command line string
NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes,
NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes,
FALSE, // handle inheritance flag
NORMAL_PRIORITY_CLASS, // creation flags
NULL, // new environment block
NULL, // current directory name
&si, // LPSTARTUPINFO lpStartupInfo,
&pi ); // LPPROCESS_INFORMATION lpProcessInformation
|
|
|
|
|
Your Question is that you don't Know where the exe is?
If this is your case, you Have a couple of directories where look for, or the app can be in any directory?
Best Regards!!!!
Carlos Antollini.
|
|
|
|
|
Try CFileFind(). Search MSDN for it.
Josh
josh@that-guy.net
|
|
|
|
|
Have a look at SearchPath and SearchTreeForFile.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
i'm in the midst of a mini project and i would like to know the library for graphics for Visual C.
library as like example: #include is for the standard input and output.
I would like to those who know to help me as i'm desperate!
Thank you!
Jan
|
|
|
|
|
What do you want this library to do ? What form does your project take (MFC/Win32/ATL/etc ) ?
GDI is there as standard, GDI+ requires you to install the platform SDK and distribute a DLL, it also does not work with Windows 95. You need GDI+ or an external library like CXImage to load and save images, but other than that I can't help unless you provide more info on what it is you need.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
thanks for replying!
i want to draw boxes with my own dimensions and maybe something like give the boxes a depression feel when the options entered from the key board.
|
|
|
|
|
the function is something like that:
void draw_menu(char na[])
{
settextjustify(0,0);
setcolor(LIGHTGREEN); //{
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
outtextxy(180,70,"Airlines"); //top inrroduction text
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
outtextxy(280,440,"Information"); //}
setcolor(15);//border
rectangle(0,0,639,479);
BOX(55,167,291,223,0,na[0],14,1,7,12); //display schedule function box
BOX(55,247,291,303,0,na[1],2,1,7,15); //display reserve function box
BOX(55,327,291,383,0,na[2],15,1,7,13); //display available function box
BOX(353,167,589,223,0,na[3],4,1,7,10); //display cancel function box
BOX(353,247,589,303,0,na[4],1,1,7,14); //display list function box
BOX(353,327,589,383,0,na[5],15,1,7,7); //display quit and save function box
return;
}
|
|
|
|
|
the function is something like that:
void draw_menu(char na[])
{
settextjustify(0,0);
setcolor(LIGHTGREEN); //{
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
outtextxy(180,70,"Airlines"); //top inrroduction text
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
outtextxy(280,440,"Information"); //}
setcolor(15);//border
rectangle(0,0,639,479);
BOX(55,167,291,223,0,na[0],14,1,7,12); //display schedule function box
BOX(55,247,291,303,0,na[1],2,1,7,15); //display reserve function box
BOX(55,327,291,383,0,na[2],15,1,7,13); //display available function box
BOX(353,167,589,223,0,na[3],4,1,7,10); //display cancel function box
BOX(353,247,589,303,0,na[4],1,1,7,14); //display list function box
BOX(353,327,589,383,0,na[5],15,1,7,7); //display quit and save function box
return;
}
and i am executing the program in dos mode.
|
|
|
|
|
A quick search of MSDN confirmed what I was pretty sure of - you're using functionality provided by your prior compiler. VC is not going to compile this code, and to be honest I have no idea how to draw boxes and so on in DOS mode. Why does your program have to be a DOS program ? How old is it ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
honestly, using this VC, it was implemented by my institue and the C language is in Windows u know like a browser kind and the program is executed in dos.......it's always in dos mode i suppose, but i know we can execute the program in windows mode but i neednt go to that yet for my project.
Jan.
|
|
|
|
|
Is this a dos program or a console application. What version of VC are you using? If it is Version 2 or greater I'd say you had a console application. Or is it using some kind of EasyWin library?
Michael
|
|
|
|
|
it's in Win32 console application
|
|
|
|
|
|