First I want to check and make sure that I can call non-system dlls and
MFC dlls at that.
Assuming that I can, I've been getting an EntryPointNotFound exception
for the follow code:
C# calling code...
[DllImport("pptcontroller.dll")]
public static extern int PPT_Start(string PPTFileName);
[DllImport("pptcontroller.dll")]
public static extern void PPT_Stop();
/*later...*/
try
{
PPT_Start( File ) ;
}
catch ( System.Exception e )
{
System.Console.WriteLine ( "PPT_Start: " + e ) ;
}
try
{
PPT_Stop( ) ;
}
catch ( System.Exception e )
{
System.Console.WriteLine ( "PPT_Stop: " + e ) ;
}
c++ dll file (PPTController.dll)
int __declspec(dllexport) PPT_Start(LPCSTR PPTFileName);
void __declspec(dllexport) PPT_Stop();
void __declspec(dllexport) PPT_Next();
void __declspec(dllexport) PPT_Previous();
void __declspec(dllexport) PPT_Goto(long page);
void __declspec(dllexport) PPT_InitInstance();
void __declspec(dllexport) PPT_ExitInstance();
__declspec(dllexport) void PPT_InitInstance()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
AfxOleInit();
}
__declspec(dllexport) void PPT_ExitInstance()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
if(m_ppt.m_lpDispatch != NULL)
{
m_oPresentation.Close();
m_ppt.Quit();
m_oPresentation.ReleaseDispatch();
m_oSSV.ReleaseDispatch();
m_ppt.ReleaseDispatch();
}
AfxOleTerm();
}
__declspec(dllexport) int PPT_Start(LPCSTR PPTFileName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
CPresentations oPresentations;
CSlideShowSettings oShow;
CSlideShowWindow oWin;
int rc = -1;
if(m_ppt.m_lpDispatch == NULL &&
!m_ppt.CreateDispatch("PowerPoint.Application"))
{
return rc;
}
else
{
// Bring the PowerPoint application to the front.
m_ppt.Activate();
oPresentations.AttachDispatch(m_ppt.get_Presentations());
// Start SlideShow
oPresentations.AttachDispatch(m_ppt.get_Presentations());
oPresentations.Open(PPTFileName,TRUE,TRUE,TRUE);
// Attach to the Active Presentation.
m_oPresentation.AttachDispatch(m_ppt.get_ActivePresentation());
// Attach to the slide-show settings.
oShow.AttachDispatch(m_oPresentation.get_SlideShowSettings());
//oShow.SetShowWithAnimation(FALSE);
//oShow.SetLoopUntilStopped(TRUE);
// Run the slide show.
oWin.AttachDispatch(oShow.Run());
int rc = ((CSlides)(m_oPresentation.get_Slides())).get_Count();
m_oSSV.AttachDispatch(oWin.get_View());
}
return rc;
}
__declspec(dllexport) void PPT_Stop()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
if(m_ppt.m_lpDispatch != NULL)
{
// Quit PowerPoint. Note, the Quit command exits
// PowerPoint without displaying any dialog boxes. So,
// any unsaved data is lost.
m_oPresentation.Close();
m_ppt.Quit();
// Free the dispatch. This sets m_lpDispatch to NULL.
m_oPresentation.ReleaseDispatch();
m_oSSV.ReleaseDispatch();
m_ppt.ReleaseDispatch();
}
}
__declspec(dllexport) void PPT_Next()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
m_oSSV.Next();
}
__declspec(dllexport) void PPT_Previous()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
m_oSSV.Previous();
}
__declspec(dllexport) void PPT_Goto(long page)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
m_oSSV.GotoSlide(page,(long)0);
}
just some code to control power point. Anyway, it doesn't seem to want
to find anything. Also, in the same code where I call PPT_Start(...)
and PPT_Stop, I call FindWindow from user32.dll. The FindWindow call
works fine. The PPT_ calls both generate EntryPointNotFound
exceptions. Any help is apreciated!
Thanks!
stu =)
Volker Hilsheimer - 21 Jan 2005 16:27 GMT
You have to extern "C" the symbols you export from your C++ DLL. Use the
"depends" tool or "dumpbin" to see what symbols your DLL exports.
Volker
> First I want to check and make sure that I can call non-system dlls and
> MFC dlls at that.
[quoted text clipped - 141 lines]
>
> stu =)
stu - 21 Jan 2005 19:18 GMT
Many many thanks. That did the trick!
michael =)