Windows.h header file code#include windows.h Sleep( sometimeinmillisecs ); // note uppercase S /codeThis is the first result when googling for 'msdn. Hello, I am new Visual C Editor.Previously I was using Turbo c Editor for my C Projects.But in case of Visual C I do not know which header file to be used,since it does nor recognise.Kindly suggest which header file to be used? The latest Visual Studio compiler do not support the depreciated standard header files any.
- 5 Contributors
- forum4 Replies
- 1,969 Views
- 7 Months Discussion Span
- commentLatest Postby asifalizaman
It should have come with your compiler. What compiler are you using? If your compiler doesn't find it, maybe the include-paths are not set correctly. Have you done a file-search for 'windows.h'?
With MinGW, you can download and extract the win32 API headers and libraries from '>this page. But, normally, this is included in the installation.
You cannot just download windows.h, because that header is just the tip of the iceberg. It's basically a header that includes just about every possible function of the Win32 API, through many underlying headers (which is, of course, an absolutely terrible way to do things, but, hey, that's Microsoft for you). Using it also requires linking to a long list of libraries (usually setup by default on your compiler configurations, when installed, or when creating a new 'windows' project).
The following program works perfectly fine on Visual C++ but doesn't compile at all in Turbo C++. I get about 40 errors - such as Turbo C++ couldn't include any of the header files (not even iostream.h) etc. Can anybody tell me how to make this program compile and run on Turbo C++? I don't usually use Turbo C++ - please explain what I must do clearly and in details. Thanks./*
Written By : Paul Maker
Description : simple ODBC example. globals are used to
make life simple here.
*/
#include <windows.h>
/* for the ODBC stuff */
#include <sql.h>
#include <sqlext.h>
/* printf etc */
#include <stdio.h>
#include <iostream.h>
/* global variables for the database environment and
connection handle */
HENV henv;
HDBC hdbc;
/* these are the dsn details, fill them as appropriate */
#define PM_DSN 'Accounts'
#define PM_DSN_USER '
#define PM_DSN_PW '
int DBopen(void)
{
int res = 0;
RETCODE retcode;
/*allocate the environment handle*/
if(SQLAllocEnv(&henv) SQL_SUCCESS)
{
/*allocate the connection handle*/
if(SQLAllocConnect(henv,&hdbc) SQL_SUCCESS)
{
/* Set login timeout to 5 seconds. */
SQLSetConnectOption(hdbc,SQL_LOGIN_TIMEOUT,5);
SQLSetConnectOption(hdbc,SQL_CURSOR_TYPE,SQL_CURSOR_STATIC);
/* Connect to data source */
retcode = SQLConnect(hdbc,
(unsigned char*)PM_DSN,SQL_NTS,
(unsigned char*)PM_DSN_USER,SQL_NTS,
(unsigned char*)PM_DSN_PW,SQL_NTS);
if(retcode SQL_SUCCESS || retcode SQL_SUCCESS_WITH_INFO)
{
res=1;
}
}
else SQLFreeConnect(hdbc);
}
else SQLFreeEnv(henv);
return res;
}
void DBclose(void)
{
SQLDisconnect(hdbc);
SQLFreeConnect(hdbc);
SQLFreeEnv(henv);
}
int DBexecute(char *sql,HSTMT *hstmt)
{
int res=0;
RETCODE retcode;
if(SQLAllocStmt(hdbc,hstmt) SQL_SUCCESS)
{
retcode = SQLPrepare(*hstmt,(unsigned char*)sql,strlen(sql));
if(retcode SQL_SUCCESS)
{
retcode = SQLExecute(*hstmt);
if(retcode SQL_SUCCESS)
{
res=1;
}
}
}
return res;
}
void DBcloseCursor(HSTMT hstmt)
{
SQLFreeStmt(hstmt,SQL_DROP);
}
void main()
{
HSTMT fstmt;
char name[100];
char name_client[100];
char myst[300];
int myvar;
cout<<'Please type the Balance value which will be used in the SQL query'<<endl;
cin>>myvar;
sprintf(myst, 'SELECT Acc, Balance FROM Table1 WHERE Balance =%d',myvar);
if(DBopen())
{
if(DBexecute(myst,&fstmt))
{
SQLBindCol(fstmt,1,SQL_C_CHAR,name,sizeof(name),NULL);
SQLBindCol(fstmt,2,SQL_C_CHAR,name_client,sizeof(name_client),NULL);
RETCODE retcode = SQLFetch(fstmt);
while(retcode SQL_SUCCESS || retcode SQL_SUCCESS_WITH_INFO)
{
cout<<name<< ' ';
cout<<name_client<<endl;
retcode = SQLFetch(fstmt);
}
DBcloseCursor(fstmt);
}
}
DBclose();
}