/////////////////////////////////////////////////////////////////////// // DemoInterface.cpp - Demonstrate Creation and proper use of // // Dynamic Link Libraries (DLLs) // // // // Language: Visual C++, ver 7.0 // // Platform: Dell Dimension 8100, Windows 2000, SP 2.0 // // Application: Demonstration for CSE775 - Distributed Objects // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DemoInterface.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } DEMOINTERFACE_API CDemoInterface* CDemoInterface::CreateDemoDll() { return new CDemoDll(); } CDemoDll::CDemoDll(void) : _changed(false) { ::GetCurrentDirectory(_PATHSIZE,_curPath); return; } void CDemoDll::setDir(const char *path) { if(!_changed) { ::GetCurrentDirectory(_PATHSIZE,_oldPath); _changed = true; } ::SetCurrentDirectory(path); ::GetCurrentDirectory(_PATHSIZE,_curPath); } const char* CDemoDll::getDir() { return _curPath; } void CDemoDll::restore() { strncpy(_curPath,_oldPath,_PATHSIZE); ::SetCurrentDirectory(_oldPath); } bool CDemoDll::changed() { return _changed; } DEMOINTERFACE_API void SetDir(const char *path) { ::SetCurrentDirectory(path); } DEMOINTERFACE_API const char* GetDir() { static char path[CDemoDll::_PATHSIZE]; ::GetCurrentDirectory(CDemoDll::_PATHSIZE,path); return path; }