|
yes i do like this,one more thing that i have done,i m using a modeless dialog box above this,for wait until fill the list.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I have got a code snippet which is very simple windows service,when i start it manually after creating it by sc command it's taking a lot of time to start, and after a long time it gives me an error message of 1053. Then the service's status becomes starting. but surprising part is the service is actually doing its work on background, although i can't stop this service(I need to restart to stop the service). Here is the code,
#include "stdafx.h"
#include "Test00.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CWinApp theApp;
using namespace std;
#define SLEEP_TIME 5000
#define LOGFILE "d:\\memstatus.txt"
SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE hStatus;
void ServiceMain(int argc, char** argv);
void ControlHandler(DWORD request);
int InitService();
int WriteToLog(char* str)
{
FILE* log;
log = fopen(LOGFILE, "a+");
if (log == NULL)
return -1;
fprintf(log, "%s\n", str);
fclose(log);
return 0;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "MemoryStatus";
ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL;
StartServiceCtrlDispatcher(ServiceTable);
}
return nRetCode;
}
void ServiceMain(int argc, char** argv)
{
int error;
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS|SERVICE_ALL_ACCESS;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
hStatus = RegisterServiceCtrlHandler(
"MemoryStatus",
(LPHANDLER_FUNCTION)ControlHandler);
if (hStatus == (SERVICE_STATUS_HANDLE)0)
{
return;
}
error = InitService();
if (error)
{
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = -1;
SetServiceStatus(hStatus, &ServiceStatus);
return;
}
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus (hStatus, &ServiceStatus);
MEMORYSTATUS memory;
while (ServiceStatus.dwCurrentState == SERVICE_RUNNING)
{
char buffer[16];
GlobalMemoryStatus(&memory);
sprintf(buffer, "%d", memory.dwAvailPhys);
int result = WriteToLog(buffer);
if (result)
{
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = -1;
SetServiceStatus(hStatus, &ServiceStatus);
return;
}
Sleep(SLEEP_TIME);
}
return;
}
int InitService()
{
int result;
result = WriteToLog("Monitoring started.");
return(result);
}
void ControlHandler(DWORD request)
{
switch(request)
{
case SERVICE_CONTROL_STOP:
WriteToLog("Monitoring stopped.");
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus (hStatus, &ServiceStatus);
return;
case SERVICE_CONTROL_SHUTDOWN:
WriteToLog("Monitoring stopped.");
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus (hStatus, &ServiceStatus);
return;
default:
break;
}
SetServiceStatus (hStatus, &ServiceStatus);
return;
}
It would be a great help if someone plz help me regarding this.
|
|
|
|
|
What was the resolution? Is the service control method called in the same thread context as the app? I would suspect not,in which case the app never gets the signal, are we not supposed to use mutexes or other local comms mechanism for sharing data between threads?
I'm only asking because I'm about to create a service myself.
Conrad -
The world waits for you to stick your neck out, it's not easy. But once you actually stand up, you do get noticed.
http://www.plcsimulator.org/
|
|
|
|
|
Hi All
I am working on VC++ 2008.When i am creating a new project then error show.
Microsoft visual studio
The operation could not be completed.No such interface supported.
Plz help me
|
|
|
|
|
MsmVc wrote: Microsoft visual studio
The operation could not be completed.No such interface supported.
Why do you always want someone to babysit you? Can't you just Google something painfully obvious like this?!
See here[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Thanks for reply...
Sorry for you comment
See first i use google then i ask question.
|
|
|
|
|
i am having an exe.it is able to run in othr pcs when i changed it as static. Nw i want 2 make it as a setup.how i can achieve this.
|
|
|
|
|
|
I see your query is answered.
In addition, DO NOT use SMS language anywhere on this site. Next, this is the C++ forum and you should only ask C/C++/MFC queries here.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: Next, this is the C++ forum and you should only ask C/C++/MFC queries here.
Are you sure? What about Win32, WinSock, GDI, application design questions... I see a lot of these.
|
|
|
|
|
OK, OK. You win the "nitpick of the week" award.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hii,
I am getting "Error Creating bitmap!" in EVC++ 4.0 on Window CE 5.0. I don't where this error came from. I am using
CreateCompatibleBitmap and BitBlt for drawing the screen. I have checked all Error codes , but no luck.
Description of Error :
It’s the SNAP window with the “error creating bitmap” message.
“Snap” is in the blue portion
“Error Creating Bitmap” in gray portion
Thanks and regards,
priyank
|
|
|
|
|
May be you can check if the device/emulator has enough memory to hold newly created bitmap.
You can also use the GetLastError() API to know the exact reason for failure.
|
|
|
|
|
Hello Friends
I m trying to change the color of dialog in win32 based application.So for that I m using
switch(msg)
{
case WM_INITDIALOG:
{
HBRUSH bgcolor = CreateSolidBrush(RGB(255,0,0));
return TRUE;
}
case WM_CTLCOLORDLG:
{
return (LONG)bgcolor;
}
}
Any other IDeas??
Thanks & Regards
Yogesh
|
|
|
|
|
Try making HBRUSH bgcolor; a global variable.
Also set the brush in DC which is received in WPARAM of WM_CTLCOLORDLG message.
|
|
|
|
|
You got that to compile?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Perhaps we're missing something...
Steve
|
|
|
|
|
A reasonable description of the problem maybe?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Hi,
I am trying to wait until the busy cursor of the mouse. I am not understanding how to get the state of the mouse cursor.
Actually i am writing a vbscript to automate a procedure. In which i have to wait for a task to complete, during which the mouse cursor shows the hourglass. Now i want to wait till the mouse cursor doesnot show the hourglass.
Anybody there who cpuld help..
Any help will do.
Thanks in advance for any help
|
|
|
|
|
Use GetCursorInfo to get the cursor information [^] and using the CURSORINFO struct you can get the cursor state, tells you whether cursor is hidden or shown [^].
But if you are looking for the window to get active then try with GetWindowInfo [^], which will give whether the specified window is active or not.
Величие не Бога может быть недооценена.
|
|
|
|
|
For code please see the below (Previous Post"
(Previous post):
<a href="http://www.codeproject.com/Messages/3303272/Re-Using-RFX_Text_Bulk.aspx">http://www.codeproject.com/Messages/3303272/Re-Using-RFX_Text_Bulk.aspx</a>[<a href="http://www.codeproject.com/Messages/3303272/Re-Using-RFX_Text_Bulk.aspx" target="_blank" title="New Window">^</a>]
I cannot get the MS Access Database to accept over 1000 chars into a column using the RFX_Text that is set to 1024 length (See Previous Post CMyDB.cpp RXF listing).
Does anyone know how to do this in MFC?
A C++ programming language novice, but striving to learn
|
|
|
|
|
This may be a restriction posed by Access, i.e., the maximum length of a text field in Access is 255. If you want to store longer strings to a database field, you may need to look for something else, such as SQL Server. For smaller applications, you may use SQLite.
|
|
|
|
|
longer data can be stored in binary format
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
But doesn't all the data fields(columns) have to be in binary? Could you please send me an example of how to do that.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I cannot get the MS Access Database to accept over 1000 chars into a column using the RFX_Text that is set to 1024 length (See Previous Post CMyDB.cpp RXF listing).
Unless the maximum was increased in Access 2007, the limit for Text fields is 255. With a memo field, you can store up to 65535 characters.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|