|
bool OpenSQLite(CString sDatabaseFilePath)
{
int nRet = sqlite3_open16((char*)(LPCTSTR)sDatabaseFilePath, &m_pSQLiteDB);
if (nRet != SQLITE_OK)
{
return false;
}
return true;
}
void CloseSQLite()
{
if (m_pSQLiteDB)
{
sqlite3_close(m_pSQLiteDB);
m_pSQLiteDB = 0;
}
}
bool ExecuteQuery(CString sQuery)
{
if(!m_pSQLiteDB)
return false;
sqlite3_stmt* pVM = 0;
const TCHAR* szTail = 0;
int nRet = sqlite3_prepare16(m_pSQLiteDB,(char*)(LPCTSTR)sQuery,sQuery.GetLength()*sizeof(TCHAR), &pVM, (const void**)&szTail);
if(nRet != SQLITE_OK)
{
const char* szError= sqlite3_errmsg(m_pSQLiteDB);
return false;
}
nRet = sqlite3_step(pVM);
if(nRet ==SQLITE_DONE)
{
// u can use results
}
else if (nRet == SQLITE_ROW)
{
// row by row
}
else
{
sqlite3_finalize(pVM);
return false;
}
return true;
}
|
|
|
|
|
Sir,
My build is sccess but whan iam running the application i am getting error like:
application was unable to start correctlly, what is the problem, revert me back asap.
|
|
|
|
|
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
|
|
|
|
|
You should read book on C to get more familiar with the loops that are avail in C.
I prefer you to read "Let Us C - Yashwant Kanetkar".
Please dont expect full code from here
well this case i can help, but what about the other cases?
So it is better to get familiar with C loops and then make a logic from your side.
All the best.
Величие не Бога может быть недооценена.
|
|
|
|
|
You need an outer loop and a inner one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Try this:
#include <iostream>
using namespace std;
void main()
{
const char *p[] = {"1", "2 2", "3 3 3", "4 4 4 4",
"5 5 5 5 5", "4 4 4 4", "3 3 3",
"2 2", "1"};
for (int i=0; i<sizeof(p)/sizeof(*p); ++i)
{
cout << p[i] << endl;
}
}
Steve
|
|
|
|
|
You've got my 5, for the best non-answer of the day.
I don't know why others gave you a "1" rating, I guess they didn't read what you were suggesting!
|
|
|
|
|
hmmm, this is a difficult one...
Can you see any pattern in it?
|
|
|
|
|
Rozis wrote: Can you see any pattern in it?
The laser pointer and cat design pattern?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
It is very simple. The following is the generic code algorithm.
int range = <any value="">;
int outer,inner;
//The following loop is for displaying pattern from 1 to n ( any value)
for( outer loop... )
{
for( inner loop... )
}
//The following loop is for displaying pattern from n-1 to 1
range -= 1;
for( outer loop... )
{
for( inner loop.... )
}
Understand the basic code flow and implement your code.
|
|
|
|
|
#include <iostream>
using namespace std;
void main(){
const static int threshold(5);
for(int i(1), d(+1); i; i += d, d = (i == threshold)? -1 : d){
for(int j(0), end(i); j != end; ++j) {
cout << i << " ";
}
cout << endl;
}
}
Getting rid of the ending space are trivial and left as an exercise .
|
|
|
|
|
I am tying to figure out and start small on retrieving hardware information.
I am making a very simple program that does this:
1.) Find processor information
2.) Write found information to a log file ".txt"
3.) Display the found information on the screen
Very simple right? So I found this Win32 Processor Class at:
Win32 Processor Class
What I dont understand is how to implement this. On the website it does not say how to utilize this code. If it does, I do not see the example that is being displayed. I just see the breakdown of the Win32 Processor class and not a typical usage scenario.
So if anyone can please provide me some clarification on how to utilize this class correctly please respond back to this with what bits of information I have failed to recognize.
|
|
|
|
|
|
the example you point to is using a technology called WMI - Windows Management Instrumentation .. some examples on general WMI are here :- http://msdn.microsoft.com/en-us/library/aa394558(VS.85).aspx[^]
they might help you get going - WMI exposes a lot, but I dont think its necessarily the easiest of technologies to use/start with - others may disagree.
If I can find another starter for you I'll post back
'g'
|
|
|
|
|
The class you saw is WMI class, i prefer to use that.
The usage of class is mentioned in link itself, just check this(http://msdn.microsoft.com/en-us/library/aa390423(VS.85).aspx)
It is WMI so you need to handle like a COM.
Well try that, else you can go for suggestion from Rejeesh.
Величие не Бога может быть недооценена.
|
|
|
|
|
Ok,
So after looking at doing this I feel I need to use WMI (Windows Management Instrumentation).
Now to make sure I understand this, WMI is a tool that windows uses to read hardware information very accurately?
Now back to the programming portion. In order for me to use Win32_Processor Class, I first have to initialize CoInitilizeEx and CoInitilizeSecurity? I am a little confused about this. The COM (Component) is a library, and this library tells WMI and the Win32_Processor Class how to communicate with hardware?
Just making sure I understand everything and trying to put everything together.
|
|
|
|
|
|
WMI is very useful, It is used because of its high performance, and its extensible event mechanism. It can used to get information of remote systems using DCOM. WMI can be used to define a permanent consumer for a event.
It works like a query, you can write the syntax of SQL to retrieve the system information.
eg:- "SELECT * FROM Win32_Process WHERE WorkingSetSize >= 10000"
This can queried from many languages.
Now to make sure I understand this, WMI is a tool that windows uses to read hardware information very accurately?
I know WMI is accurate, but dont know whether APIs are not.
Just read the WMI architecture, http://msdn.microsoft.com/en-us/library/aa394553(VS.85).aspx.
and read the various COM API that can be useful
http://msdn.microsoft.com/en-us/library/aa389276(VS.85).aspx
I am sure your doubts are no longer going to sustain.
Величие не Бога может быть недооценена.
modified on Sunday, March 28, 2010 1:20 AM
|
|
|
|
|
Hi everyone:
I´m just starting with visual c++ 2008 and have put some code for showing a window, the code don't send any error message... the thing is that when i run it, it don't show at all... can someone help please??
thanks!!
Code:
#include <afxwin.h>
class COurApp: public CWinApp
{
public:
virtual BOOL IntInstance();
};
class COurWnd: public CFrameWnd
{
public:
COurWnd()
{
Create(0,L"Ventana con MFC");
}
};
BOOL COurApp::IntInstance(void)
{
m_pMainWnd=new COurWnd;
m_pMainWnd->ShowWindow(m_nCmdShow);
return TRUE;
}
COurApp AnApplication;
|
|
|
|
|
Use the MFC app wizard. Seriously. It's not worth dinking around with it manually.
|
|
|
|
|
Check the function name InitInstance(). If it is misspelt, there will be no window.
|
|
|
|
|
As sthalasayanam told, if everything is correct and you are able to build the project successfully, then definitely the problem is with 'misspelled InitInstance'
|
|
|
|
|
Ups.... That was it.... thankyou very much pals! problem solved XD
|
|
|
|
|
Hi. I'm porting some projects which were orignally built using VC98 (part of Visual STudio 6) to VS2008. So that we can get rid of VS 6 and have everything under VS2008.
Some of the projects are ATL & MFC projects, which apparently is just fine under VS 6, but not in VS2008.
Some of the projects, I have been able to port by removing the MFC includes from the stdafx.h and just including <atlstr.h> where they just needed support for CString.
But some are more MFC intensive. Here's the stdafx.h includes from one:
#include <afxwin.h> // MFC core and standard components
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
This configuration throws C2065 Undeclared Identifier, C2133 Unknown Size, and C2512 No appropriate default constructor errors. (I guess it can't find the ATL classes.)
If I change the configuration to:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <afxwin.h> // MFC core and standard components
I get Error 1 fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h 16 editclm
error.
Help is greatly appreciated.
|
|
|
|
|
Hmmm... So I guess this is really a hard thing...
|
|
|
|