|
Take most C++ files generated by MFC AppWizards and you will find code similar to this at top of every source file...
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
So.... Why would you want to do that?
These are the only reasons I could locate...
#define TRACE ::AfxTrace
#define THIS_FILE __FILE__
#define ASSERT(f) \
do \
{ \
if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
AfxDebugBreak(); \
} while (0) \
#define VERIFY(f) ASSERT(f)
#define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
#define DEBUG_ONLY(f) (f)
// Memory tracking allocation
void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
#define DEBUG_NEW new(THIS_FILE, __LINE__)
#if _MSC_VER >= 1200
void AFX_CDECL operator delete(void* p, LPCSTR lpszFileName, int nLine);
#endif
#ifdef _DEBUG
#define DAO_CHECK(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) AfxDaoTrace(f, #f, THIS_FILE, __LINE__)
#else
#define DAO_CHECK(f) AfxDaoCheck(f, NULL, NULL, 0)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, NULL, NULL, 0, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) f
#endif
Anyways, I mentioned it in case you had included a macro in some header file that had something similar to a statement such as that, so your full file path was ending up as a static variable in every source file.
|
|
|
|
|
Thank you ...
Im not using Dao so I hope that last part of code does not apply to me. And I though that all asserts are turned off in Release version (through #ifdef _DEBUG) ... sigh, so looks like its hopeless
|
|
|
|
|
Hi I have a database..application..
I used CDatabase and CRecordSet to minipulate database.
the db has memo fields and i have no problem inserting the data using sql statement into db.. but when I try to get back.. by using while loop and recordset.movenext()to
get the data back.. I got the error message which is
"Data truncate".
example
<br />
while(!records->IsEOF())<br />
{<br />
..<br />
..<br />
records->MoveNext(); <----- get error on reading the record that has long string data. but indeed it was only 356words in it.<br />
}<br />
}
If I delete that data or shorten the data length.. I got no error..
why am i having error when I get the data back from database and why there is no error when inserting the same data?
|
|
|
|
|
Goto your CRecordset::DoFieldExchange member function.
Enlarge the buffer for text field exchange like:
RFX_Text(pFX, _T("[REMARK]"), m_REMARK,1000);
adjust the numer "1000" to your max characters of the corresponding field.
I remember the default max length for text field is 255, you would get the truncate error message if data length exceed it.
|
|
|
|
|
Anyone, help pls !!! Can I use a .dll file if I don't have the .h file ?
I saw some discutions on this subject, where it says that it is possible to generate the .lib file from a given .dll. OK, but then how could I know what are the parameters of the functions exported by that .dll ?
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B131313[^]
I seem to remember steps for doing this being available at the SQLite web site also, may wanna check that place out in the FAQ or something...I just quickly looked and couldn't find it, but i'm sure something is there about how to do this...however i'm not sure about the header file...
HTH
I wonder if there are any animals that actually have to think in order to breathe? It would really suck to be them!!!
|
|
|
|
|
Thx, the article from microsoft is enough for me ... But what about those freakin' animals ?
Q: why a blonde died when her headphones were removed ?
A: cause she was hearing: now inhale, now exhale, now inhale, now exhale ...
|
|
|
|
|
Hi guys,
I have been trying to resolve this for a couple of days already. I hope someone out there will be able to help me out here.
Introduction:
I created a "wrapper" executable, which "implements" interface required to be run as windows service. This executable has set of configuration files, which are used to prepare environment and define another binary to be run as a service.
So the wrapper - during its own start-up - creates a new process from those configuration files.
Problem:
The starting and stopping works fine, but when I start the service from some user context (Administrator) and then I log off, the child process is being killed and my service wrapper detects that and stops.
The service configuration uses LocalSystem as the user context.
The weird part is that if I do this through a RDP connection, the child process stays alive even after logoff.
Snippet:
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.lpDesktop = "";
si.hStdOutput = hChildStdOut;
si.hStdInput = hChildStdIn;
si.hStdError = hChildStdErr;
BOOL ok = CreateProcess(NULL, lpszCmd, NULL, NULL, TRUE, // handles inherited
CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP , NULL, lpszPath, &si, piProcInfo);
Thanks in advance,
Peter
|
|
|
|
|
I think because you are creating your program attached to the current users's desktop, when the user logs off, your main window is terminated because the desktop is destroyed. Isn't there a hidden desktop that the services use? Perhaps you should attach to that instead.
|
|
|
|
|
Hi Blake,
thanks for your response...
You're probably referring to this part:
si.lpDesktop = "";
I tried to use lpDesktop with NULL value as well, and the child process was supposed to inherit the desktop from the parent process. However that did not work either...
Thanks,
Peter
|
|
|
|
|
What I meant was that the lpDesktop would NOT be NULL or EMPTY. It needs to be set to the name or handle of the desktop where the services are run. Any windows started on the desktop of the user are going to recieve all sorts of messages about termination when the user logs off.
It is best, if possible, to write services that have NO USER Interface whatsoever. Interact with them via TCP/IP, local RPC, DCOM, memory mapped files, service control commands, etc. Anything but windows!
|
|
|
|
|
Yes - I understood it correctly.
I was just saying that if you initialize STARTUPINFO.lpDesktop with NULL value desktop will be inherited (that's from MSDN).
So if the process which creates this child process is a service (that is my case), they should be on the same desktop, am I right?
My service has no user interface - it's plain process, which listens for the requests...
Thanks again,
Peter
|
|
|
|
|
I added a code, where I am quering the desktop of the current thread (running service wrapper) and retrieving its name. Then I used the retrieved desktop name for the new child process creation. It did not help. And the desktop name value retrieved in the code was "Default", which is weird I think...
code fragments:
HDESK hDesk = GetThreadDesktop(GetCurrentThreadId());
GetUserObjectInformation(hDesk, UOI_NAME, lpszDesktopName, ...);
...
si.lpDesktop = lpszDesktopName;
...
CreateProcess(..., &si, ...);
Thanks,
Peter
|
|
|
|
|
I am sorry now, I do not know what else to suggest
|
|
|
|
|
I read an interesting article about a logon session broker written by K.Brown published @ MS site:
http://www.microsoft.com/msj/0200/logon/logon.aspx[^]
So I have done one more test and I used
Service-0x0-3e7$\\Default
as a value for DesktopName in STARTUPINFO, but it did not help either. My child process still dies after session log-off.
Thanks,
Peter
|
|
|
|
|
Hi,
I'm having a nightmare with argument passing using OLE automation.
I have created an automation DLL using Visual C++. it's to be used in VB. I want to create a function within this DLL which accepts an array of object as argument. I know how to do that for a single object using the LPDISPATCH argument type but now what if I want an array of this object? I have tried many solutions but none of them worked...
I hope someone will be able to help me!
Jeff
|
|
|
|
|
I wrote a regular MFC dll which should display a dialog-box.
I have a class derived from CDialog to display my dialog.
Now, my exported class is a regular one (NOT MFC) which has a method Open to open the dialog.
(I use a regular class since my client is a console application or none-MFC client)
The problem is that i get assert on AfxGetResourceHandle().
When i added the statement "AFX_MANAGE_STATE(AfxGetStaticModuleState( ));"
i got a link error saying:
"mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in RewinderSimulator.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in RewinderSimulator.obj".
How can i solve my problem?
Thanks,
Dudi
|
|
|
|
|
I would like to clip one region from another. But how to get points array from HRGN????
|
|
|
|
|
Have a look at CRgn::GetRegionData() .
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I wrote a little COM dll, that placed on one machine, and client programm on another. The machine where com dll is placed - wiht Windows XP, and client program works properly if it on WIndows XP, and doesn't work if it on Windows 2000 Proffessional or Server, i haven't tried it on another OS. What's wrong am i doing? It shows the messagec "Invalid pointer".
|
|
|
|
|
My first guess would be a missing or unregistered DLL that is used by your DLL.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
But how can it be??? I just call the dll from another computer....
As i said on the Windows XP the client programm works, but on another platform doesnt.
As i understand the DCOM - it should make a connection throught the net, and call the methods of my COM. So, may be deal in ports??? which ports used DCOM? - i've never seen that information...
Or maibe i shoud make the instance of My com another way than CoCreateObject???
|
|
|
|
|
open dilaog after 15 years does not work propertly.
Do a simple app. Make it enter MTA.
Pop up a Common Open/Save File Dialog.
On Win2K Hangs When Selecting topmost My Documents Folder.
On Win XP, By selecting my computer the list view is empty.
On both OS-es sometime list of files is chopped (if does not hang meanwhile).
I would apreciate any workaround.
But after 15 years they could not get it right a ... so common open dialog...
|
|
|
|
|
around.:
[code]
class COd : public CFileDialog
{
public:
COd(BOOL bOpenFileDialog,
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL):CFileDialog(bOpenFileDialog,
lpszDefExt ,
lpszFileName ,
dwFlags ,
lpszFilter ,
0 )
{
}
int DoModal(){
return CFileDialog::DoModal();
}
BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
BOOL ret = CFileDialog::OnNotify(wParam, lParam, pResult);
OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
switch(pNotify->hdr.code)
{
case CDN_TYPECHANGE:
{
CWnd* pWnd = GetActiveWindow();
CWnd* PDlg = pWnd;
if(pWnd)
{
GetFocus()->PostMessage(WM_KEYDOWN,VK_RETURN,0);
GetFocus()->PostMessage(WM_KEYUP,VK_RETURN,0);
}
}
break;
}
return ret;
}
virtual void OnFolderChange()
{
TCHAR cs[128];
CWnd* pWnd = GetActiveWindow();
CWnd* PDlg = pWnd;
CWnd* PSlv = 0;
int relation = GW_CHILD|GW_HWNDFIRST;
while(pWnd = pWnd->GetWindow(relation))
{
GetClassName(pWnd->m_hWnd, cs,128);
if(!strcmp("SHELLDLL_DefView",cs))
{
CWnd* pSave = pWnd;
int relation = GW_CHILD|GW_HWNDFIRST;
while(pWnd = pWnd->GetWindow(relation))
{
GetClassName(pWnd->m_hWnd, cs,128);
if(!strcmp("SysListView32",cs))
{
PSlv = pWnd;
break;
}
relation = GW_HWNDNEXT;
}
pWnd = pSave;
}
relation = GW_HWNDNEXT;
}
}
};
class DlgWrap
{
public:
DlgWrap(BOOL bOpenFileDialog,
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL)
{
memset(&m_ofn,0,sizeof(m_ofn));
_cfilter = lpszFilter;
_cfilter.Replace('|', '\0');
m_ofn.lStructSize = sizeof(m_ofn);
m_ofn.lpstrDefExt = lpszDefExt;
m_ofn.lpstrFile = (LPTSTR)lpszFileName;
m_ofn.Flags = dwFlags ;//| OFN_EXPLORER;
m_ofn.lpstrFileTitle = "asdfasd";
m_ofn.lpstrFilter = (LPCTSTR)_cfilter ;
/*
m_ofn.nMaxFileTitle = MAX_PATH;
m_ofn.hwndOwner = pParentWnd->m_hWnd;
m_ofn.lpstrFilter = lpszFilter;
*/
//// m_ofn.Flags = dwFlags | OFN_EXPLORER;
//// strFilter.Replace('|', '\0');
}
UINT DoModal()
{
_hThread = ::CreateThread(0,0,(LPTHREAD_START_ROUTINE)ThrProc,this,0,0);
Sleep(1208);
WaitForSingleObject(_hThread, INFINITE);
return _rv;
}
static UINT ThrProc(void* pThis)
{
OPENFILENAME ofn = {0};
DlgWrap* pDlg = (DlgWrap*)pThis;
HRESULT hr = CoInitialize(0);
memcpy(&ofn, &pDlg->m_ofn, sizeof(ofn));
pDlg->_rv = ::GetOpenFileName(&ofn);
memcpy(&pDlg->m_ofn, &ofn, sizeof(ofn));
CoUninitialize();
return pDlg->_rv;
}
DWORD _rv;
HANDLE _hThread;
OPENFILENAME m_ofn;
CString _cfilter ;
};
[/code]
|
|
|
|
|
I need to disable a CListCtrl item, and can't find out how. It looks like SetItemState() will do it, but I can't find what to set. Any help? Thanks
BW
The Biggest Loser
"Farm Donkey makes us laugh. Farm Donkey hauls some ass." -The Stoves
|
|
|
|
|