|
Hi All,
I am developing a service for win 2000 on VC++, that service accesses the databse to retreive some information like user id etc. I am using CDatabase and CRecordset classes for accessing the database. but the problem is that when i call a method (that access the database) from the main service loop, it reports a Run time Error, and after that Service Application terminates. the line is
CDatabase db;
db.OpenEx("DSN=MailMove;SERVER=LOCALHOST;UID=;PWD=;DATABASE=;");
This is working fine in regular MFC Application (eg dialog based) but when i call the same method through the service's main loop, it reports the error.
Please point out any one knows about what is going wrong. Its an urgent.
Thanks in advance.
bye
Asim
|
|
|
|
|
A guess:
Run() on Win32 Service is generally executed on different thread.
And CDatabase (may/may not) need MFC initialisation before its being invoked.
And AfxWinInit is used to initialse MFC for non-MFC applications.
Add the following line in the very begining of the Run() Method
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, NULL, 0))
{
cerr << "MFC failed to initialize!" << endl;
return 1;
}
and maybe an instance of CWinApp. Check AfxWinInit API in MSDN for more details.
Hope this helps!
Ram
|
|
|
|
|
Hi,
Thanks for replying,
I have inserted the code that u have asked, but this code is causing a
"Debug Assertion Failed!"
error. Please tell me how to tackle the problem. I have an Application that can run in two modes, i.e. GUI MFC Application and NT Service.
Please reply as soon as Possible.
Thanks alot
Asim
|
|
|
|
|
Hi world...
I've created a CPropertySheet dialog, but I want to put this dialog inside another that I've created myself (with others components: editbox, etc.)
How to do that?
I dont want use CTabCtrl... But the result is almost the same one.
Thanks in advance...
Hello World!!!
from Raphaël
|
|
|
|
|
1. Insert a CStatic in the dialog.
2. Create the CPropertysheet modeless and set it's parent window as he CStatic inserted.
Hope this helps.
|
|
|
|
|
this->m_pPSEstacio = new CPSEstacio("", this, 0);
this->m_pPSEstacio->Create(this, WS_CHILD | WS_TABSTOP);
this->m_pPSEstacio->ModifyStyleEx(0,WS_EX_CONTROLPARENT);
this->m_pPSEstacio->ModifyStyle(0,WS_VISIBLE);
|
|
|
|
|
Hello,
I have a DLL that I've written and I have it's lib file.
I would like to import one function of that DLL using that lib file.
I'm on the DEBUG link version of a Service, and in the Project->Settings->Link->Object library modules I've included the path to that lib file.
I've placed the DLL inside the same directory of the service.
When I edit the source code of the service in the VC++6 editor and I write down the name of the function that I want to import, a tooltip appears with the guidelines of how to continue writting that function (parameters and so on...)
Ok.
after having said this, when I try to link the code I receive this error message:
C:\blablabla.cpp(357) : error C2065: 'bActivarHook' : undeclared identifier
Generating Code...
Error executing cl.exe.
bActivarHook is the function that I want to import.
any idea?
Thank you in advance.
bla.exe - 1 error(s), 0 warning(s)
|
|
|
|
|
I dont know if I have understood your situation but I suppose that you have added the header file of your DLL (defined the exported functions) into the project that use your DLL?
I suppose... because you have writed:
When I edit the source code of the service in the VC++6 editor and I write down the name of the function that I want to import, a tooltip appears with the guidelines of how to continue writting that function (parameters and so on...)
Hello World!!!
from Raphaël
|
|
|
|
|
No,
let me explain better, my english is not my best...
1. I have a DLL that installs a system wide keyboard hook that exports a function lets call it FxA.
2. In the project of the service that will launch that function (FxA) I've added the LIB file of the DLL going to the menu item: (Project -> Settings -> Link) and writting there the path to that lib file.
3. Once this has been done, I try to use that function from my service calling it directly (i.e: FxA(true); )
but when I link the service App. the linker tells me that:
error C2065: 'FxA' : undeclared identifier
Generating Code...
Error executing cl.exe.
SCTATL.exe - 1 error(s), 0 warning(s)
And I don't know why.
I'm sure that I'm missing something important, but I cannot remember what it is.
Do you know what I'm missing in order to be able to import that function?
NOTE:
when I've written:
When I edit the source code of the service in the VC++6 editor and I write down the name of the function that I want to import, a tooltip appears with the guidelines of how to continue writting that function (parameters and so on...)
I meant that when in the source code I have written the name of the function ("FxA(") and a "(" then a tooltip appears with the right type of parameter that I must enter... and this makes me to think that the VisualC++ knows the existence of that FxA function.
NOTE2:
Have I helped you with the Property sheet affair?
|
|
|
|
|
did you have omitted this?
#ifndef DLLEXPORT
#define DLLEXPORT _declspec(dllexport)
#endif
DLLEXPORT void FxA(bool bValue);
in your header file... (I repeat: you must to add this header file to your service project)
Joan Murt wrote:
Have I helped you with the Property sheet affair?
I'm trying... thanks...
Hello World!!!
from Raphaël
|
|
|
|
|
er...
You was right
I had not placed that file there...
that was a big mistake!
Thank you very much, you've helped me.
|
|
|
|
|
dear all,
i am using the following code to get root directory and then find out the file system.
but it gives an error Specified Path iS Invalid!
what wrong have i done!
is there any other (better) way to do it!
plz. help!!!
DWORD dwError;
CString RootPathName;
CString RootDir;
UINT i = GetWindowsDirectory(RootPathName.GetBuffer(MAX_PATH),MAX_PATH);
RootDir= RootPathName.Mid(0,2);
AfxMessageBox(RootDir);
BOOL bFSResult = GetVolumeInformation (RootDir.GetBufferRootDir.GetLength)),
NULL,
0,
NULL,
NULL,
NULL,
FileSystem.GetBuffer(MAX_PATH),
MAX_PATH);
dwError = GetLastError();
AfxMessageBox(FileSystem);
|
|
|
|
|
UINT i = GetWindowsDirectory(RootPathName.GetBuffer(MAX_PATH),MAX_PATH);
RootPathName.ReleaseBuffer();
RootDir= RootPathName.Mid(0,3);
rechi
|
|
|
|
|
This is my code for it : (I don't prefere using CString with APIs and this is just because I feel it's easier to use char)
char WinDir[MAX_PATH];
char Vol[4];
char FileSystem[10];
UINT i = GetWindowsDirectory(WinDir,MAX_PATH);
AfxMessageBox(WinDir);
strncpy(Vol,WinDir,3);
Vol[3]='\0';
AfxMessageBox(Vol);
BOOL bFSResult = GetVolumeInformation (Vol,
NULL,
0,
0,
0,
0,
FileSystem,
10);
AfxMessageBox(FileSystem);
|
|
|
|
|
Hi !
I started yesterday to write my first MDI app (with MFC, let's get at it slowly ). This is a kind of text viewer, maybe editor (Yes, another one but i think it's a good example to start). You may say there is not much to do, but ...
Anyway, my first problem is that i'd like the child windows to be maximized when a document is opened. Currently the child window is about half the size of the screen, in the middle. Since the main frame is maximized at startup, i'd like the child win to be maximized also.
So i intercetpted the CREATESTRUCT from the PreCreateWindow in CMDIChild class, and did :
cs.style|=WS_MAXIMIZE;
But this would not change anything. I tried this in several other places, and also with ShowWindow(WS_MAXIMZED) , but no way, my win is still not maximized. What's wrong ?
~RaGE();
|
|
|
|
|
Try:
ShowWindow(SW_MAXIMIZE);
((CMDIFrameWnd *)AfxGetMainWnd())->RedrawWindow(NULL, NULL,
RDW_INVALIDATE | RDW_ALLCHILDREN);
or MDIMaximize() .
rechi
|
|
|
|
|
Thanks. I'll give it a try.
I did not think it was that complicated : your hint seems a little bit tricky (Do not get me wrong, I just mean that I usually use the AfxGet**() functions when I did not get anything else to work ). Is it possible that the Child Window initially have wrong system metrics (so that it thinks that the maximized size is the size that it actually has on startup, i.e. not the screen size ) ?
[Look at MSDN]
Oh, I think MDIMaximize should be what I need.
Big thanks
~RaGE();
|
|
|
|
|
Rage wrote:
Is it possible that the Child Window initially have wrong system metrics
I don't know.
I have tried to overwrite MyChildFrame::Create and to modify the style before calling CMDIChildWnd::Create but nothing happened. The call to ShowWindow(SW_SHOWMAXIMIZED) - which, by the way, equals MDIMaximize() - remained a must.
But, if you want to do it with a SDI window - 100% API stuff - the metrics work perfectly and are not forgotten. You have to call ShowWindow(SW_SHOW) and the window appears as maximized. This seems to be the natural windows' behaviour - for API SDI, at least.
rechi
|
|
|
|
|
Ok tried yesterday evening. It was really that the Child window had the wrong system metrics for it to work with modifying the style in the CREATESTRUCT of PrecCreateWindow() .
Also tried with MDIMaximize() surprisingly did not work, whereas ShowWindow(SW_SHOWMAXIMIZED) works perfectly (In fact, i can rememeber i tried ShowWindow(SW_SHOWMAXIMIZED) in PreCreateWindow instead of Create before posting my initial thread, and this did not work. Solution was to do it in Create instead.
Well, it works, so lots of thanks for your help anf for you having bothered to try out.
RaGE
Sorry for the pidgin english, it's fast-written.
|
|
|
|
|
Dear All,
Good Day ...
I need to add the scrolling cabapility a propertyPage dailog how can i do that.
Plz help...
Thanks,
Best Regards,
Mohammad Zakarni
|
|
|
|
|
Does anyone of u here know how to create an OLE object in VC++??
Also, anyone have a sample source/project that allow VC++ program to add,delete,edit and search functions?? I need them urgently as i am a newbie to VC++! And are told to do a program interfacing the Microsoft Access database... I had a program that can run add,delete and edit function but i can't get my search function working... do anyone of you have a reference that i can refer to?
Thanks in advance!
Elise
|
|
|
|
|
Why this Code make the System Icon Crazy?
Can you tell me how to solve the problem?
CMainFrame::CMainFrame()
{
bFirst=true;
CShellPidl pidl((UINT)CSIDL_DESKTOP, m_hWnd);
SHFILEINFO sfi;
ZeroMemory(&sfi, sizeof(SHFILEINFO));
HIMAGELIST hSysImageList = (HIMAGELIST) SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)pidl,
0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
theApp.m_smallSystemIcon.Attach(hSysImageList);
ZeroMemory(&sfi, sizeof(SHFILEINFO));
hSysImageList = (HIMAGELIST) SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)pidl,
0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_LARGEICON);
theApp.m_largeSystemIcon.Attach(hSysImageList);
}
CMainFrame::~CMainFrame()
{
theApp.m_smallSystemIcon.Detach();
theApp.m_largeSystemIcon.Detach();
theApp.SalvaListe();
if (m_hLanguageDLL)
FreeLibrary(m_hLanguageDLL);
}
Best regards
Margaria Ivano
|
|
|
|
|
I want to load more that one bitmaps from files, into memory, arrange them vertically and then save the result in a single bmp file. If you know any such sample code or want to give advice then please ???
|
|
|
|
|
Hey all, justtrying to get the item which the user has doubled clicked in a WTL CListview derived class i have. Been looking and trying a few things with no luck. I'm not even sure what message I should be handling, any ideas?
thanks in advance
Luke.
|
|
|
|
|
Hi,
I am a beginner in VC++. Programatically I want to list the services Name & the port No of the service that listeing to .
Like Telnet 23
Smtp 25
http 80 etc.
Can anyone help me to find the solution of this problem?
Thanks in advance
San
|
|
|
|