|
What did you try to do to ready the file backwards?
What is the exact problem that you're facing?
Try and debug the program to see what and where the problem occurs.
|
|
|
|
|
If the file is small enough to fit in memory read it into a buffer backwards.
==============================
Nothing to say.
|
|
|
|
|
Sumesh Somanathan wrote: But its not working.
When you go to the doctor or take your car to the mechanic, do you simply say "I don't feel well" or "It's not working" and leave it at that? If so, consider yourself lucky to be in the company of mind readers.
"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
modified 28-Oct-11 10:34am.
|
|
|
|
|
If he goes to the doctor and says that..... I want more doctors from that part of the world!!
|
|
|
|
|
|
I have created an ownerdraw menu in MFC Dilaog in VC++ 2010.But i have added Command is added to this menu item.But the function associated with this command is not firing.When i disable the Ownerdraw the command get fired.
Please help me .
Thanks in Advance
|
|
|
|
|
Please use your debugger to isolate the failing code and then post that extract so people can see what is actually happening.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Can't really see how the drawing would affect an event from being triggered (or messages from reaching intended window target)... post relevant code.
|
|
|
|
|
|
Hello All,
I wanted to create an application which do something, say popup message box after every 10 min. I wanted to create MFC application.And wanted to show running application icon in task bar (near clock). What should I do. Can you please suggest similar and how can I achieve same with C#?
Regards.
|
|
|
|
|
|
CWnd::SetTimer allows you to : say popup a message box every 10 min.
just put relevant code in CWnd::OnTimer
void CMainFrame::OnStartTimer()
{
m_nTimer = SetTimer(1, 2000, 0);
}
void CMainFrame::OnStopTimer()
{
KillTimer(m_nTimer);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
MessageBeep(0xFFFFFFFF);
MessageBox(HWND_DESKTOP,"Text here","Text here",MB_OK);
CMDIFrameWnd::OnTimer(nIDEvent);
}
|
|
|
|
|
|
Hello,
When I try to build the QuickWin source (download link: http://www.codeproject.com/KB/dialog/quickwin.aspx) I get some errors. I *have* done it (built it the same way) several years ago using an earlier version of Visual Studio.
Looks like it should be easy to overcome, but I'm not sure how to proceed.
Here's a good example to start with:
c:\projects\quickwin\quickwin\quickwin.h(28) : error C2504: 'CRedirect' : base class undefined
And here's the entire build output (BTW, I am *not* worried about warnings.):
1>------ Build started: Project: QuickWin_Project, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>QuickTst.cpp
1>c:\projects\quickwin\quicktst\quicktst.cpp(20) : warning C4996: 'gets': This function or variable may be unsafe. Consider using gets_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(279) : see declaration of 'gets'
1>c:\projects\quickwin\quicktst\quicktst.cpp(26) : warning C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _stricmp. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(215) : see declaration of 'stricmp'
1>StdAfx.cpp
1>ChildView.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>c:\projects\quickwin\quickwin\quickwin.h(28) : error C2504: 'CRedirect' : base class undefined
1>c:\projects\quickwin\quickwin\quickwin.h(66) : error C2146: syntax error : missing ';' before identifier 'm_WinPlace'
1>c:\projects\quickwin\quickwin\quickwin.h(66) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\quickwin\quickwin\quickwin.h(66) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\quickwin\quickwin\quickview.h(26) : error C2065: 'BUFFER_SIZE' : undeclared identifier
1>c:\projects\quickwin\quickwin\childview.cpp(17) : error C2653: 'CChildView' : is not a class or namespace name
1>c:\projects\quickwin\quickwin\childview.cpp(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\quickwin\quickwin\childview.cpp(19) : warning C4508: 'CChildView' : function should return a value; 'void' return type assumed
1>c:\projects\quickwin\quickwin\childview.cpp(21) : error C2653: 'CChildView' : is not a class or namespace name
1>c:\projects\quickwin\quickwin\childview.cpp(21) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>LppDlg.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>MainFrm.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>ParamDlg.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>ProcessDlg.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>QuickView.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>c:\projects\quickwin\quickwin\quickview.cpp(74) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
1>QuickWin.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>c:\projects\quickwin\quickwin\quickwin.cpp(45) : warning C4996: '_splitpath': This function or variable may be unsafe. Consider using _splitpath_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(786) : see declaration of '_splitpath'
1>c:\projects\quickwin\quickwin\quickwin.cpp(63) : warning C4996: '_splitpath': This function or variable may be unsafe. Consider using _splitpath_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(786) : see declaration of '_splitpath'
1>c:\projects\quickwin\quickwin\quickwin.cpp(116) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
1>c:\projects\quickwin\quickwin\quickwin.cpp(118) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
1>c:\projects\quickwin\quickwin\quickwin.cpp(120) : warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
1>c:\projects\quickwin\quickwin\quickwin.cpp(124) : warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
1>c:\projects\quickwin\quickwin\quickwin.cpp(159) : warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
1>c:\projects\quickwin\quickwin\quickwin.cpp(195) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CQuickWinApp::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>Redirect.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>c:\projects\quickwin\quickwin\redirect.cpp(110) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
1>c:\projects\quickwin\quickwin\redirect.cpp(395) : warning C4267: 'initializing' : conversion from 'size_t' to 'DWORD', possible loss of data
1>ToolBar.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>c:\projects\quickwin\quickwin\toolbar.cpp(95) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
1>WinPlace.cpp
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
1>Generating Code...
1>Build log was saved at "file://c:\Projects\QuickWin\Debug\BuildLog.htm"
1>QuickWin_Project - 10 error(s), 15 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any ideas are appreciated.
Matt
|
|
|
|
|
You should post on the articles forum section for a better response.
Having said that, where does the CRedirect class reside.
You're either missing some file or some path is not set to find the include file.
Please check the additional include directories option in the project properties.
|
|
|
|
|
Or his compilation order has changed (for whatever reason)...
|
|
|
|
|
I need to get a registry value which is REG_MULTI_SZ, so I can get each name and go on to the next registry key and get the version number.
In regedit the values are
MSSQLServer
MicrosoftSMBiz
SQLExpress
The raw data that I pull out is. eg is verbatim
'M' '0' 'S' '0' 'S' '0' 'Q' '0' 'L' '0'
The end of each word is '0' '0' '0' and the very end is '\0\0\0\0'
My goal is to make a char array that can run through strtok_s,
So I wrote this, but overall in the end, I want to terminate the new array with '\0', so I can remeasure the length of characters. I wanted to return a value that is not the full 1024.
char rgValue[1024];
char szInstance[1024];
Get the Registry value
// do work
ndx = 0;
szRgVal = sizeof(rgValue);
for(int i=0; i < szRgVal; i++) {
if (!rgValue[i] == '\0\0\0') {
szInstance[ndx++] = rgValue[i];
}
else {
szInstance[ndx++] = ';';
}
i++;
}
maxStr = strlen(szInstance);
szInstance[maxStr-0] = (char)'\0';
I really wanted to terminate the char array at the end of the chars so I can get the strlen of 36 or so, but strlen is always 1033 1024.
MSSQLServer; MICROSOFTSMLBIZ; SQLEXPRESS;\0TTTTTTTTTT
Here is my question.
Is my for loop bad coding practice? Or should I try to add the '\0' in the for loop at the end of the chars I want, and then remeasure with strlen?
|
|
|
|
|
So I modified it a bit, and I got what I wanted, oh. I passed the value back the calling function as a char, and extracted the names out of the char array, and called the version registry function, so far no side effects.
ndx = 0;
doubleZero = false;
szRgVal = sizeof(rgValue);
for(int i=0; i < szRgVal; i++) {
if (!rgValue[i] == '\0\0') {
szInstance[ndx++] = rgValue[i];
doubleZero = false;
}
else {
if (doubleZero == false) {
szInstance[ndx++] = ';';
doubleZero = true;
}
else {
szInstance[ndx++] = '\0';
break;
}
}
i++;
}
maxStr = strlen(szInstance);
szInstance[maxStr-0] = (char)'\0';
printf(" SQL Server Instance: %s %i\n", szInstance, strlen(szInstance) );
|
|
|
|
|
if statement is very wrong
'\0\0\0' quote will be used as a single '\0' character
and the ! sign not the equation modifies to != , it will be a bool negation of rgValue[i] character and gives true when rgValue[i] is '\0' and false otherwise and this bool value will be compared to the '\0\0\0' value what is false as bool type
I recommend this:
ndx = 0;
szRgVal = sizeof(rgValue);
for(int i=0; i < szRgVal; i++) {
if (rgValue[i] == '\0' && rgValue[i+1] == '\0' && rgValue[i+2] == '\0' && rgValue[i+3] == '\0') {
szInstance[ndx++] = '\0'; break;
}
else {
if (rgValue[i] == '\0' && rgValue[i+1] == '\0' && rgValue[i+2] == '\0') {
szInstance[ndx++] = ';'; i++;
}
else
szInstance[ndx++] = rgValue[i];
i++;
}
|
|
|
|
|
I thought about that, how can I compare 2 bytes in a row with i that represents 1 byte. Didn't think about i+1 and i+2 and so forth.
I had the right idea at least!
After I wrote the first version I posted, I started wondering if I was crazy, in the way I handled the returned value.
I wasn't expecting a code rewrite that is paste and go!, but I thank you for taking the time to do so. Nice to know I was on the right track, and I actually learned something this week.
Sincerely
jkirkerx
|
|
|
|
|
This part doesn't work, it never registers, I ran the code through debug and stepped through it, but it's hard to follow the 3 zero sequence.
Day is over, get back to it tomorrow, no worries I will figure it out.
else {
if (rgValue[i] == '\0' && rgValue[i+1] == '\0' && rgValue[i+2] == '\0') {
szInstance[ndx++] = ';';
i++;
}
|
|
|
|
|
One word: UNICODE.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I thought about that last night,
Should I just left it as unicode, so it don't run into the lang issue down the road when I make the french version.
|
|
|
|
|
Stop, stop!
You have totally misinterpreted the data you are looking at. This is a Unicode (aka UTF16) string where each character is 16 bits wide rather than the 8 used by ASCII. You must either convert the string to ASCII in order to process it correctly (via WideCharToMultiByte() [^]), or make your program Unicode aware. I would also be interested to know how you are extracting this value from the registry as I was under the impression that strings are automatically converted for non-Unicode programs.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This is code I copied from the net and modified in the my first week of c++. In the other uses of the code, I used a CString, but this time i needed to modify the results. It didn't dawn on me till I was bowling last night that the result is Unicode, and I should leave it as Unicode, so I can support French and Spanish. I think SQL Server Instances can be named UniCode, thus that's why the registry values are stored that way.
Alright, lesson learned.
char* CA_Registry::_get_SQLServer_InstalledInstances( void )
{
HKEY keyHandle;
char rgValue[1024];
char szInstance[1024];
CString regPath = L"SOFTWARE\\Microsoft\\Microsoft SQL Server\\";
CString regReq = L"InstalledInstances";
DWORD size1 = sizeof(rgValue);
DWORD Type;
DWORD dwType = 0;
DWORD regStatus = REG_MULTI_SZ;
int ndx=0;
int szRgVal=0;
int maxStr=0;
bool doubleZero;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, regPath, 0, KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS) {
dwType = REG_MULTI_SZ;
regStatus = RegQueryValueEx( keyHandle, regReq, NULL, &Type, (LPBYTE)rgValue, &size1);
switch ( regStatus ) {
case ERROR_SUCCESS:
ndx = 0;
doubleZero = false;
szRgVal = sizeof(rgValue);
for(int i=0; i < szRgVal; i++) {
if (!rgValue[i] == '\0\0') {
szInstance[ndx++] = rgValue[i];
doubleZero = false;
}
else {
if (doubleZero == false) {
szInstance[ndx++] = ';';
doubleZero = true;
}
else {
szInstance[ndx++] = '\0';
break;
}
}
i++;
}
maxStr = strlen(szInstance);
szInstance[maxStr-0] = (char)'\0';
printf(" SQL Server Instance: %s %i\n", szInstance, strlen(szInstance) );
RegCloseKey(keyHandle);
cout << "key was read successfully\n";
break;
case ERROR_MORE_DATA:
cout << "Buffer too small\n";
break;
default:
cout << "Count not read key\n";
}
}
else {
cout << "Can not open key";
cin.ignore();
}
int strSize = sizeof(szInstance);
char *szReturnValue = new char[strSize];
for(int i = 0; i < strSize; i++) {
szReturnValue[i]=szInstance[i];
}
maxStr=strlen(szReturnValue);
szReturnValue[maxStr-0]=(char)'\0';
return szReturnValue;
delete [] szReturnValue;
}
|
|
|
|