|
OK, that makes the problem much simpler then.
With MFC, you could use CFile or a CStdioFile for this purpose. It's very easy, and here's a sample: http://www.codeproject.com/Messages/3136266/Re-Getting-string-from-a-Text-file.aspx[^]
The sample code reads data, but you could easily create the file, and write and read from it with the member functions of this class.
- Create the file by passing the appropriate arguments to the constructor. Example on this page: http://msdn.microsoft.com/en-us/library/7b61hcx0(v=vs.90).aspx[^]
- Write data into it using the WriteString[^] method.
When you create the file, make sure that the extension is .CSV and format your string correctly such that it's comma separated before writing it into the file. Let me know if you need any more help.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
It has two monitor, main and expand monitor.
The expand monitor in the top with higher resolution ratio, and the main minitor in the bottom.
But if I drag a window to the expand monitor and then double click to show maximium, it has problem, it cannot fill of the windows of the expand monitor? why ? It save the main monitor rectangle info, how to change it.
modified 15-Oct-13 5:13am.
|
|
|
|
|
yu-jian wrote: It has two monitor What does - your PC or something else? And, what does this have to do with C++?
Veni, vidi, abiit domum
|
|
|
|
|
I had resolved this problem,
Use EnumDisplayMonitors to judge which monitor the application is in.
And then set the new maxmium position for the application.
|
|
|
|
|
Hi,
I need to set the DisableProcessWindowsGhosting(VOID) function in an application developed in VC6.0
The problem is that Windows.h that comes with that old programming environment does not know this function yet. What do I have to include in order to get access to that function?
|
|
|
|
|
You need to upgrade to a later version of Visual Studio or Visual Studio Express.
Veni, vidi, abiit domum
|
|
|
|
|
The problem is that my app still has to support Windows NT 4.0
Additionally, I guess it is part of the latest platform SDK available for VC6, I just wonder how to configure my project settings correctly...
|
|
|
|
|
You could try getting a later version of the Windows SDK, but you would still need a down version of the app for NT 4.0.
Veni, vidi, abiit domum
|
|
|
|
|
DisableProcessWindowsGhosting() is supported with XP SP1 and later. If your app must support older Windows versions, you must check the version. You can use late binding by getting the function address with GetProcAddress()[^]:
typedef void (WINAPI* LPFN_DisableProcessWindowsGhosting)();
HINSTANCE hInst = ::GetModuleHandle(_T("User32"));
if (hInst)
{
LPFN_DisableProcessWindowsGhosting lpfnFunc =
(LPFN_DisableProcessWindowsGhosting)::GetProcAddress(hInst, "");
if (lpfnFunc)
lpfnFunc();
else
TRACE("DisableProcessWindowsGhosting() is not supported\n");
}
This will also solve your problem regarding the old SDK header files.
|
|
|
|
|
|
well, you asked the question in the correct spot - on that article
Asking it here (again) is superfluous - if you dont get a response from hackzai you may have to narrow the issue down to a piece of code, and then post a specific question here with that code, rather than such an open question
'g'
|
|
|
|
|
Please do not keep repeating the same question. Also, as this is in reference to a CodeProject article you should post in the forum at the end of the article so the author can help you.
Veni, vidi, abiit domum
|
|
|
|
|
This image implies that you can simply import a binary ".exe" resource: http://i.stack.imgur.com/ITdYs.jpg
But how to do this in VS2012 c++? It does not allow me to import an .exe: http://i.stack.imgur.com/zdzbV.png
I'm trying this tutorial:
http://www.codeproject.com/Articles/4221/Adding-and-extracting-binary-resources
modified 13-Oct-13 20:58pm.
|
|
|
|
|
If you have a question about a particular article, you should post it at the end of the article.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Do you know how to solve this problem or not???
|
|
|
|
|
I would like to build a self extracting .exe in Visual Studios c++ 2012.
Does anyone have a working solution for VS2012?
I checked projects like LZMA (7-zip SDK), but it doesn't seem to mention self extracting '.exe' anywhere.
http://ck.kolivas.org/apps/lrzip/lrzip-0.615/lzma/lzma.txt
I check NSIS and inno-setup, but those product don't seem to offer 1 click install.
I checked 'Chilkat v9.4.0' but that is not free!
http://www.chilkatforum.com/questions/2354/how-to-write-a-self-extractor-for-the-windows-os
Those codeproject.com files are so outdated that they give me a lot of errors in VS2012:
http://codeproject.com/Articles/4221/Adding-and-extracting-binary-resources
http://codeproject.com/Articles/7053/Pure-WIN32-Self-Extract-EXE-Builder
|
|
|
|
|
I have found a very interesting incident of memory leak in my code. Although I have not been able to find the root cause of the leak still thought to share with you all. I will really appreciate any help on this. I am rather curious to know how come a memory leak can be seen in use of CString in such a simple way.
Code:
We have a thread function:
UINT __cdecl LogWriteThread(void *pParam)
{
CLog* pLog = (CLog*)pParam;
UNUSED_ALWAYS(pParam);
try
{
pLog->LogWriteFunc();
}
.................
.................
return 0;
}
UINT __cdecl CLog::LogWriteFunc(void *pParam)
{
..........
CString cstrLogDataBuffer = m_cstrLogLine;
m_cstrLogLine = _T("");
CopyLogToFileByThread(cstrLogDataBuffer);
}
void CMpmLog::CopyLogToFileByThread(const CString& cstrLogDataBuffer)
{
....................
const long iLength = cstrLogDataBuffer.GetLength();
char *pBuffer = new char[iLength + 1];
for (long iIndex = 0;iIndex < iLength; iIndex++)
{
pBuffer[iIndex] = (char)cstrLogDataBuffer.GetAt(iIndex);
}
pBuffer[iLength] = '\0';
const unsigned int uiWriteLen = fwrite((const void *)pBuffer, sizeof(char),iLength, m_pofLogStream);
delete[] pBuffer;
....................
}
========================
If I commment call for "CopyLogToFileByThread" in function LogWriteFunc then memory leak goes away. But thats not the solution.
Manoj
Never Gives up
|
|
|
|
|
The shown code part of CopyLogToFileByThread() does not change a CString object. So this can't be the source of the leak it is from a CString object.
It seems that you are accessing the m_strLogLine CString object by multiple threads. When doing so, you must use locking. To do so, you may add a CCriticalSection member to your class and use this for locking:
CSingleLock singleLock(&m_CritSection);
singleLock.Lock();
CString cstrLogDataBuffer = m_cstrLogLine;
m_cstrLogLine = _T("");
singleLock.Lock();
Use similar code when changing or reading m_strLogLine anywhere.
One more note:
Instead of converting a TCHAR string to char by casting each char, you may use WideCharToMultiByte() or the conversion provided by CString :
CStringA strLineA(cstrLogDataBuffer.GetString());
fwrite(strLineA.GetString(), sizeof(char), strLineA.GetLength(), m_pofLogStream);
|
|
|
|
|
Thanks Jochen for your inputs.
1. I have used CriticalSection while accessing m_cstrLogLine but have omitted those additional lines to focus on actual business logic.
2. I agree that WideCharToMultiByte() could have been a better option to convert string but I have changed code to rule out any leak during conversion itself.
3. The CopyLogToFileByThread() is not modifying string and thats why its surprising to have memory leak from that function.
4. One more point i will like to mention here is thhat this application has been built for WinCE 6.0.
I am trying to replicate the same issue with a test application and if possible for XP.
Manoj
Never Gives up
|
|
|
|
|
Manoj Kumar Rai wrote: I have found a very interesting incident of memory leak in my code. How are you verifying this?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
POINT Point;
::GetCursorPos(&Point);
HWND hWnd = ::WindowFromPoint(Point);
::PostMessage(hWnd, WM_KEYDOWN, 'a', NULL);
I sent a message WM_KEYDOWN to hWnd.
It is activate on Windows Notepad..
but on games like need for speed, it isn't activate..
how do i do?
|
|
|
|
|
Thats because it probably doesn't use the windows message pump for keyboard and mouse interaction.
|
|
|
|
|
Games like need for speed doesn't use the usual windows messages system. Your application responds when your window gets the message through WindProc and the message loop . The way which is used in games is entirely different.
A cool video :- http://www.youtube.com/watch?v=XLCe-hQ8lgE[^]
"If A is a success in life, then A=x+y+z. (Work is x; y is play; and z is keeping your mouth shut.)"
|
|
|
|
|
Hello!
I had an error in my project created with QT and C++
I created Server which gets data from AudioInput and gives it to UDP Socket, there is no problem, but in Client's project I had a problem, when I tried to write data to AudioOutput device after UDP Socket gets this data from net
in my project error was in this line "int l = audioSource->read(audioBuffer,input);" in
"qaudiooutput_win32_p.cpp"
and this is Call Stack at time debugging which shows this
QtMultimediad4.dll!QAudioOutputPrivate::deviceReady() Line 579 + 0x1c bytes C++
QtMultimediad4.dll!QAudioOutputPrivate::qt_static_metacall(QObject * _o=0x00b53308, QMetaObject::Call _c=InvokeMetaMethod, int _id=1, void * * _a=0x00b51d20) Line 52 + 0x8 bytes C++
what I did wrong
PLEASE HELP!!!!!
|
|
|
|
|
Mkhitar Sargsyan wrote: what I did wrong You forgot to tell us what the error was.
And please use <pre> tags around your code so it is readable, like so:
int l = audioSource->read(audioBuffer,input);
Veni, vidi, abiit domum
|
|
|
|