⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atllocalsrv.cpp

📁 VC++串口通信设。本书详细说明讲解了在VC++环境下编写串口通信得过程。值得一看
💻 CPP
字号:
// Get needed include files
#include "PizzaMakeImp.h"
#include "ATLLine.h"


//
// Object map, indicates which classes are serviced by this server
//
BEGIN_OBJECT_MAP(ObjectMap)
   OBJECT_ENTRY(CLSID_PizzaMaker1, ComPizzaMaker)
END_OBJECT_MAP()


//
// The global module object
//
QueATLModule _Module;


//
// Standard start function for a Windows executable
//
extern "C" 
int WINAPI WinMain (HINSTANCE   hInstance, 
                    HINSTANCE   /*hPrevInstance*/,
                    LPSTR       pszCommLine, 
                    int         /*nShowCmd*/)
{
   // Process our command-line
   CATLCommandLine CommLine(pszCommLine);

   // Crank up COM
   HRESULT hResult = CoInitialize(NULL);
   if (FAILED(hResult)) {
      ReportError("Could not initialize OLE subsystem.", hResult);
      return FALSE;
   }

   // Setup the module object
   _Module.Init(ObjectMap, hInstance);

   // Do we need to self-register?
   if (CommLine.Register())
      hResult = _Module.RegisterServer();

   // Do we need to self-unregister?
   if (CommLine.Unregister())
      hResult = _Module.UnregisterServer();

   // Everything's looking good -- startup the server?
   if (CommLine.ShouldRun())
   {

      // Register the class factories with COM
      hResult = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, 
                                             REGCLS_MULTIPLEUSE);
      if (FAILED(hResult)) {
         ReportError("Could not register class factories.", hResult);
         return FALSE;
      }

      // Main server message loop
      MSG msg;
      while (GetMessage(&msg, 0, 0, 0))
         DispatchMessage(&msg);

      // Unregister class factories
      _Module.RevokeClassObjects();
   }

   // Bring down COM
   CoUninitialize();

   return hResult;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -