|
a simple way (but not necessarily portable to non-MS systems (I only use VC++ versions) is to put a line like this in stdafx.cpp
#pragma comment(lib,"version.lib")
which will put a comment in the STDAFX.OBJ file to tell the linker to search that library.
Steve S
Developer for hire
|
|
|
|
|
Downloader and Install files from the WEB (Like the Windows Updates)
Hi everybody.
I'm trying to create a web application with C#.net or C++ like the (windows updates from Microsoft) to let the customer of our company download automatically our executables files from the web and also let the web app automatically the install those files on their computers.
If somebody has any idea of how to do it or any source code about it, I’d appreciate.
Thanks
Ali Hidalgo
|
|
|
|
|
I would suggest that you abandon the idea of doing it from your browser (the way that win update does). Just a few of the reasons that this is a bad idea are:
* Most network admins have disabled installation of the applet you would need for this.
* In order for the applet to install securely you would need to purchase a certificate from a certificate authority (a fairly expensive proposition considering the alternative is free)
* C++ is completely incapable of doing this unless you develop it using a plug-in (which is a very difficult way of doing such a simple thing). C# and Java are both too limited when ran as applets to make the possibly needed registry changes.
* Even if you got past all of this, it is still far more inconvienent for the user to go find your download section of the website than it is for them to select an option in the menu of the prog they are already using.
* An application can be setup to automaticaly check for newer versions without the user needing to bother with it.
The better way to handle this problem is by using either C# or C++ to write a seperate app that simply downloads the files into the correct directories and makes any registry changes needed.
This application will follow this basic program flow:
1. Check FTP server for newer version of the installation file. A good way to do this is to use a specific file naming convention and comparing that to a set of variables in the main app (in .NET apps this is already availible through the App object). These can be sent to the updater app via the command line, DDE or OLE (whatever you are most comfortable with).
2. If newer file is found, then download.
3. After download completes close any running instances of the main app and run the install app you just downloaded.
If you don't want the user to see an installation wizard each update...you could make your own installation routines that does the same things as an instalation wizard but this will be more difficult for you and only save the user a few occasional clicks. Technically, you should have it first uninstall the old version before installing the new but if you don't do that, it shouldn't cause too many problems as long as you don't register the prog each update. Depending on which installer you are using their should be some way to set that.
|
|
|
|
|
I have a program that needs some way of getting a generic resource and loading it as a normal file. I would prefare to work with io streams, but I don't have too. I know how to load an image or a cursor or an icon, but they just return HBITMAP or HCURSOR or HICON.
Thank you in advanced
|
|
|
|
|
Check out the FindResource() , LoadResource() , and LockResource() APIs, using those you can get the raw data of a resource.
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Hi all:
I am still learning c++, so I will try to describe my problem and what I am try to do the best I can.
The basis of my program is to take data from the Serial I/O Port into a character array and analyze it and do all kinds of stuff with it. Right now what I am trying to do is take a byte (I am working with whole numbers, so my byte would = 2 characters) and compare it against a table of possible matches and if the byte matches, go to the function that corresponds with that byte.
I'll give an example here:
Lets say the whole number integer is 48. Now I want to take 48 and compare it against a list of commands (00 to 99) and if one matches go to the routine of that matching number. so when it compared 48 against 48 in the table it would then call the cmd48() function and go from there.
I hope I have been as clear as possible, so that you can understand what it is I am trying to do.
NOTE: I dont think a switch-Break statement would work since it only checks 1 character and obviously I am not working with only 1 character, so I dont know anything else to use.
Thanks
|
|
|
|
|
Your best bet would be to use function pointers in a lookup table. Assuming all the functions return void and take no parameters...
void (*functions[])() = { cmd0, cmd1, cmd2, cmd3 };
...
char string[3] = "48";
int number = atoi(string);
if (number >= 0 && number <= 3)
{
(*functions[number])();
} Just make sure that you never index your array out of bounds, or you'll have huge problems, and the errors probably won't make any sense. The first element in the array will be if a 0 is received, the second element for a 1 received etc.
Hope this helps
PS. Look up a textbook on function pointers if you're not sure how they work.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Im developer of network security. and i have write program that create some PC hiden on network and i have problem of how i can hide logical driver not only in windows explorer but denied fully access to it .
faroq from yemen thammar
working in thammar universty and my intersted about network and security
im programmer from 6 years ago and ihave my B.C from this universty
|
|
|
|
|
For starters, you can remove the C$ and ADMIN$ shares on that machine. You can also go into the LAN Properties dialog and uncheck File and Printer Sharing.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ineed to remotley send files from one machine to the other by only one program on one machine .
please some source code (VC6)
with my thanks
faroq from yemen thammar
working in thammar universty and my intersted about network and security
im programmer from 6 years ago and ihave my B.C from this universty
|
|
|
|
|
This is actually impossible. Net cards (or any other piece of hardware) do not have the ability to create files (yes drives can make files but this is actually because the OS tells them how to). Fortunately any OS that is capable of networking also includes programs to convert data sent over the network into files (this is called an abstraction layer) that makes it as simple to do as saving any other file. This means that to save a file in a shared network directory all you need to do is save it to a network path. The source directory must have read permissions and the destination directory must have write permissions and be shared on the network as such. Different OSes have different ways to set these options. After you have the permissions setup you can use any file operation you want to do this. For example, to copy the file C:\dat.txt to //sysb/inc/dat.txt you could use the API function CopyFile like so:
CopyFile("c:\dat.txt", "//sysB/inc/dat.txt", FALSE);
sysb would be the name of the other computer and inc would be the shared directory.
|
|
|
|
|
Dear All,
I am developing a Win32 Application in Windows API VC6.0, I need to use an MS Access 2000 Database to connect to. Reading some of the Articles on codeproject site, but could not decide what is the best to use:
ADO
COM
DAO
ODBC
My Appliction need to run smootly on Windows 9x, 2k and XP?
=======================
Just reading the Article: Express OLE DB Library: An ideal data access solution for C++ By Ghanshyam Naik, I decided to use ODBC for my project.
Any help is appreciate to connect to MS ACCESS using ODBC (NOT MFC) or using MFC Classes in Win32 and Win API Programming.
WinAPILaerner
|
|
|
|
|
WinAPILearner wrote:
...but could not decide what is the best to use:
"Best" is a subjective term. It all depends on what you are after as to what technology you would use. How big is the database? How many connections are you expecting to support? Can the database be accessed by more than one connection at a time? How many transactions-per-second do you expect? Does the database need to be backed up while in use? This is not an all-inclusive list of questions.
WinAPILearner wrote:
Any help is appreciate to connect to MS ACCESS using ODBC (NOT MFC) or using MFC...
You want to connect to an Access database without using MFC, but you want help with MFC. Is that correct?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Dear David Crow,
I would like to use ODBC, Win API in a Win32 Application, my Database is just a catalog. Select ProductID in listbox and then Show Other Information in a Static text windows.
I found this Interesting Article but it is MFC, I want the same thing in Win API.
href="http://www.codeproject.com/database/readdb.asp#xx467253xx">
Using the CDatabase class to read an Access databases
I posted my code to the author, I will appreciate if you have a look at.
Thanks
|
|
|
|
|
WinAPILearner wrote:
I would like to use ODBC, Win API in a Win32 Application,
Check out functions like, but not limited to:
SQLGetData
SQLExecDirect
SQLFetch
SQLPutData
SQLConnect
SQLSetParam
... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_api_reference.asp
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
With all of the examples available on MSDN and Google, what specifically is giving you grief?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Did you look at these examples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlconnect.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlbindcol.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlgetdata.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_with_sqlconnect.asp
http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/ad/samples/cli/s-dbmcon-c.htm
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Under the odbcsqlconnect.asp I copied this sample code, but it give me 9 Errors. Some others do not have samples. I get a lot of errors including any SQLxx.h files.
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
/*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Set the ODBC version environment attribute */
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Allocate connection handle */
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Set login timeout to 5 seconds. */
SQLSetConnectAttr(hdbc, (void*)SQL_LOGIN_TIMEOUT, 5, 0);
/* Connect to data source */
retcode = SQLConnect(hdbc, (SQLCHAR*) "TEST", SQL_NTS,
(SQLCHAR*) "tUser", SQL_NTS,
(SQLCHAR*) "tPass", SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
// ;
// ;
// ;
//
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
|
|
|
|
|
WinAPILearner wrote:
...but it give me 9 Errors.
And those errors would be?
WinAPILearner wrote:
Some others do not have samples.
All of the links I provided have examples.
WinAPILearner wrote:
I get a lot of errors including any SQLxx.h files.
What are they?
How are you using this code snippet? What other .h files have you included?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
following is my implimentation
#include <windows.h>
#include <odbcinst.h>
#include <sqldb.h>
............ Other codes
void FillListBox (HWND hwndList)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
/*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Set the ODBC version environment attribute */
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Allocate connection handle */
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Set login timeout to 5 seconds. */
SQLSetConnectAttr(hdbc, (void*)SQL_LOGIN_TIMEOUT, 5, 0);
/* Connect to data source */
retcode = SQLConnect(hdbc, (SQLCHAR*) "TEST", SQL_NTS,
(SQLCHAR*) "tUser", SQL_NTS,
(SQLCHAR*) "tPass", SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
//SendMessage (hwndList, LB_ADDSTRING, 0, (LPARAM) "TEST") ;
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : error C2143: syntax error : missing ')' before '*'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : error C2143: syntax error : missing ';' before '*'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : error C2059: syntax error : ')'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : error C2061: syntax error : identifier 'PDBPROCESS'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : error C2501: 'DBERRHANDLE_PROC' : missing storage-class or type specifiers
e:\program files\microsoft visual studio\vc98\include\sqldb.h(57) : error C2226: syntax error : unexpected type 'SQLAPI'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(59) : error C2146: syntax error : missing ';' before identifier 'SQLAPI'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(59) : error C2373: 'DBERRHANDLE_PROC' : redefinition; different type modifiers
e:\program files\microsoft visual studio\vc98\include\sqldb.h(56) : see declaration of 'DBERRHANDLE_PROC'
e:\program files\microsoft visual studio\vc98\include\sqldb.h(59) : fatal error C1004: unexpected end of file found
Error execu
|
|
|
|
|
You must include sqlfront.h before sqldb.h .
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
e:\program files\microsoft visual studio\vc98\include\sqlfront.h(126) : error C2146: syntax error : missing ';' before identifier 'LPINT'
e:\program files\microsoft visual studio\vc98\include\sqlfront.h(126) : error C2040: 'PTR' : 'int' differs in levels of indirection from 'void *'
e:\program files\microsoft visual studio\vc98\include\sqlfront.h(126) : fatal error C1004: unexpected end of file found
Now geting 3 Errors in sqlfront.h
|
|
|
|
|
In what order do you have the #include statements?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am writing a program that runs another program and prints the second program's output in first's console, but the second program's output is printed before output in the first program.
Here's my code
<br />
#include <windows.h><br />
#include <tchar.h><br />
#include <iostream.h><br />
<br />
void main(void)<br />
{<br />
PROCESS_INFORMATION pi;<br />
STARTUPINFO si;<br />
<br />
ZeroMemory(&si,sizeof(STARTUPINFO));<br />
si.cb = sizeof(STARTUPINFO);<br />
<br />
cout << _T("Starting ver...\n");<br />
<br />
if(CreateProcess(NULL, _T("cmd /c ver"), NULL, NULL,<br />
TRUE, 0, NULL, NULL, &si, &pi))<br />
{ <br />
DWORD ExitCode = 0;<br />
DWORD ErrorCode = 0;<br />
<br />
do<br />
{<br />
Sleep(100);<br />
if(GetExitCodeProcess(pi.hProcess, &ExitCode) == 0)<br />
{<br />
cout << _T("GetExitCodeProcess Error: ");<br />
cout << GetLastError() << endl;<br />
}<br />
}while(ExitCode == STILL_ACTIVE);<br />
<br />
CloseHandle(pi.hThread);<br />
} <br />
cout << _T("Finsihed with ver\n");<br />
}
and here is the program output
Microsoft Windows XP [Version 5.1.2600]
Starting ver...
Finsihed with ver
The program should output "Starting ver..." before it runs version. The output doen't change if I use printf instead of cout either.
Does anybody know of a solution? It has me stumped.
Thanks in advance.
-Joe
|
|
|
|
|
cout buffers the data before it writes it to the screen. Try using cout.flush() before creating the process to force the buffer to be written to the screen immediately.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|