Dart Home | PowerTCP WebServer for ActiveX | Custom Development | Reply | PowerTCP WebServer for ActiveX Topics | Forums |
Author | Forum: PowerTCP WebServer for ActiveX Topic: Web Server as a Service |
mljames From: Indianapolis, IN USA Posts: 9 Member Since: 02/21/03 |
posted February 21, 2003 4:26 PM I'm trying to run the web server as an NT service. However, contrary to the service example that was sent with my software, I do not want any kind of interface on it. Generally, when we write services, we write them as console applications with C++. However, I don't know if this is feasable given that this is an ActiveX control. Since I haven't worked with ActiveX control all that much, I have a series of questions about the potential of my solution: - Does the control require the Windows Message Loop to function? Can it run within a console? If so, are there any examples of this control in a non-Windows application? - If not, does there exist any objects that are not ActiveX controls? Are there any straight C++ objects that could be used? - Is there another option that I'm not seeing? Any help would be appreciated. Thanks, Matt James |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted February 21, 2003 4:39 PM - Does the control require the Windows Message Loop to function? Yes. - Can it run within a console? If so, are there any examples of this control in a non-Windows application? Yes it can, but there are no samples. There is an extremely small demand for such use and the amount of work that would go into a sample would require consulting rates. - If not, does there exist any objects that are not ActiveX controls? Are there any straight C++ objects that could be used? The only straight C++ option that we have is the older PowerTCP Pro, but all you would get with that would be a Daemon control and you would have to do all the HTTP stuff from scratch. - Is there another option that I'm not seeing? Create the app with a window that's not visible. Just because you put the control on a window doesn't mean that you need to show it. |
xs From: Murfreesboro, TN USA Posts: 2 Member Since: 03/29/04 |
posted March 29, 2004 11:37 PM Hello, I must disagree that the need for running the web server component as a service (or console) app is small. I was having the same problem, so I whipped up a quick and dirty sample. This code is just slapped together to prove it will work. The source follows: #include "stdafx.h" #include "WebServer.h" HWND hwndMain; LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); CWebServer webServer; int APIENTRY WinMain( HINSTANCE hinstance, // handle to current instance HINSTANCE hinstPrev, // handle to previous instance LPSTR lpCmdLine, // address of command-line string int nCmdShow) { MSG msg; BOOL bRet; WNDCLASS wc; // Register the window class for the main window. wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION); wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "WndClass"; if (!RegisterClass(&wc)) return FALSE; // Create the main window. hwndMain = CreateWindow("WndClass", "Sample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND) NULL, (HMENU) NULL, hinstance, (LPVOID) NULL); CoInitialize(NULL); webServer.Create(""); DartWebServer::IWebServerPtr pWebServer = webServer.pWebServer; try { pWebServer->RootDirectory = _bstr_t("c:\\"); pWebServer->LogDirectory = _bstr_t("c:\\"); pWebServer->MaxIdleTime = 1; pWebServer->Start(85, -1, _bstr_t(""), _bstr_t(""), 0, 0); } catch(_com_error e) { char buffer[2048]; wsprintf(buffer,"ERROR #%d: %s", e.HelpContext(), (char *)e.Description()); MessageBox(NULL, buffer, "err", MB_OK); } // Show the window and paint its contents. ShowWindow(hwndMain, nCmdShow); UpdateWindow(hwndMain); // Start the message loop. while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) { if (bRet == -1) { // handle the error and possibly exit } else { TranslateMessage(&msg); DispatchMessage(&msg); } } return 0; } LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return 0; } |
xs From: Murfreesboro, TN USA Posts: 2 Member Since: 03/29/04 |
posted March 29, 2004 11:41 PM After reading the original post again I sortof misunderstood the question. I see the poster was talking about without a message loop. Actually the code should still work in a windows service, just don't display the window. |
Reply | PowerTCP WebServer for ActiveX Topics | Forums |
This site is powered by
![]() |