|
I use, n works for me :-P
GenLocalDSNString("Microsoft Access Driver (*.mdb)", "DSN=myDSN", "Description=Connection to local database", strPath,"FIL=MS Access");
}
void GenLocalDSNString(CString Driver, CString DSN, CString Desc, CString path, CString FIL)
{
BOOL failed=FALSE;
TCHAR strConnect[256];
int i = 0;
Concat(strConnect, DSN, &i);
Concat(strConnect, Desc,&i);
Concat(strConnect, "DBQ=", &i);
i = i-1;
Concat(strConnect, path,&i);
Concat(strConnect, FIL,&i);
SQLConfigDataSource(NULL,ODBC_REMOVE_SYS_DSN, Driver, strConnect);
//try to create a system DSN - if this fails create user DSN
if(!SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN, Driver,strConnect))
failed = TRUE;
if(failed)
{
failed = FALSE;
if(!SQLConfigDataSource(NULL,ODBC_CONFIG_DSN, Driver,strConnect))
failed = TRUE;
}
if (failed)
{
AfxMessageBox("DSN Creation Failed. Please Contact Support",MB_ICONWARNING);
}
}
void Concat(LPTSTR strDest, LPCTSTR strSrc, int* pnInt)
{
memcpy(strDest+*pnInt, strSrc, _tcslen(strSrc)+1);
*pnInt += _tcslen(strSrc)+1;
}
|
|
|
|
|
Where to place the actual hook code?
In CMainFrm or CWinApp.
|
|
|
|
|
WOW, I found a very good free firewall, and it open full source code!!
The more details: http://www.filseclab.com/eng/products/firewall.htm, http://www.filseclab.com/eng/products/sourcecode.htm
|
|
|
|
|
Hi,
I am a new in MFC.
I want to call a dialog box on Help button on a propety sheet in MFC.How can I do this?
Please guide me.
rajesh
|
|
|
|
|
I use the PlaySound() API function to play wav files when events occur in our app. I would like to give the user the option of adjusting the volumn of each sound.
Im guessing I will need to record the current volumn, set the volumn to the users preferance, play the sound and reset to the original value.
Does anyone know how to do that?
Thanks
Josh
|
|
|
|
|
Hi guys,
I found using the CEdit control in Visual Studio .NET, if the control's ES_NUMBER is set (numbers only), a ballon type of notification is automatically implmented and will pop-up when the users try to type non-number character in the edit box. It works on my first app. However, this special effect no longer works in my second app when using the same standard CEdit control. Typing non-number character will make the error sound, but no longer prompts the ballon notification.
What could have prevented from happening?
Thanks
|
|
|
|
|
Hi
I am currently building a time-critical app that requires a lot of computation functions, like sin(), log(), and sqrt(). I have two questions regarding this:
1. Is there an alternative way that is faster than using those functions? I am working on unsigned ints (32-bit) data, and building a lookup table would not be feasible, since there is no known boundary on the data.
2. Will C++ STL algorithm like for_each(), accumulate(), etc. make my app run faster than using traditional for loop? I am using VC++ 6.0 BTW, without STLPort.
Thanks!
|
|
|
|
|
(1)The FPU can perform the basic sin/cos/ln functions in 'hardware' and therefore presumably quite quickly, more quickly than an integer based hand coded approach. So I suggest you convert your incoming fixed point data to floating, process it, then convert it back, examine the generated machine code and measure the performance. Only then explore the options. If you use the C library functions 'double sin( double ) ' etc then the compiler should generate inline FPU code.
(2)I don't think you'll see a significant performance difference for or against with the STL algorithms, but their use should make the code cleaner.
Paul
|
|
|
|
|
Ex: I want to list all the Folder that shared or shared fully in my Drive. How to do? help me please ??
thanks
|
|
|
|
|
If you don't want to write any program for the same , try following.
If you are talking about C or D drive, go to root of the drive & fire following command.
"dir /S /ON /AD /B > AllFolder.txt"
All the folder will be listed in AllFolder.txt
|
|
|
|
|
Yes, i wanna write a program in MFC to list all the Folder that Shared fully in Hard Drive (C:; D . But I don't know how to approach, Could you help me any more??
thanks
|
|
|
|
|
Hi
If I'm not wrong, an element in STL map is a pair of <key, data>. Given a map of a number of elements, how can I use STL algorithms like for_each(), accumulate(), etc on just the data, ignoring the keys?
Thanks!
|
|
|
|
|
The parameter of the for_each predicate is the result of dereferencing an iterator, which in the case of a map is a map<key,value>::value_type , or pair<const key,value> . So the predicate can look at the second member of the pair :
#include <map>
#include <algorithm>
typedef map<char,int> mymap;
struct TotalIt
{
void operator()( mymap::value_type elt )
{
m_total += elt.second;
}
int m_total;
TotalIt() : m_total(0) { }
};
int main()
{
mymap M;
M['a'] = 1;
M['b'] = 2;
M['c'] = 3;
M['d'] = 4;
M['e'] = 5;
for_each ( M.begin(), M.end(), TotalIt() );
}
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
If my rhyme was a drug, I'd sell it by the gram.
|
|
|
|
|
How about this?
#include <iostream>
#include <map>
#include <iterator>
#include <numeric>
template <typename I> class Pair2ndIterator : public I
{
public :
Pair2ndIterator ( I i ) : I ( i )
{
}
typename I::value_type::second_type& operator* ()
{
return (I::operator*()).second ;
}
} ;
template <typename I> Pair2ndIterator<I> MakePair2ndIterator ( I it )
{
return Pair2ndIterator<I> ( it ) ;
}
int main()
{
std::map<char, int> mymap ;
mymap.insert ( std::make_pair ( 'a', 10 )) ;
mymap.insert ( std::make_pair ( 'b', 11 )) ;
mymap.insert ( std::make_pair ( 'c', 12 )) ;
mymap.insert ( std::make_pair ( 'd', 13 )) ;
mymap.insert ( std::make_pair ( 'e', 14 )) ;
std::cout << "Accumulate ( mymap ) = " <<
std::accumulate ( MakePair2ndIterator ( mymap.begin ()),
MakePair2ndIterator ( mymap.end ()), 0 ) ;
return 0;
}
Paul
|
|
|
|
|
How can I append data to an existing file without overwriting the contents? I thought I could position the pointer at the end using SeekToEnd() and then write to it but it doesn't work that way. Thanks!
|
|
|
|
|
Position the file pointer at the end of the file before writing to it:
SetFilePointer ( hFile, 0, NULL, FILE_END );
[edit]Corrected order of the parameters[/edit]
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Fascinating - in some of my code, I used:
SetFilePointer( hFile,
0,
NULL,
FILE_END);
i.e. I have FILE_END and 0 reversed - this also works fine.
I wonder how often you can swap parameters in an API call!
|
|
|
|
|
|
This means I'd have to open the file using CreateFile(). I'm using CFile::Open() to open the file so is there a way to do it this way? I need to create a report that needs to follow a specific format and I'm writing to the file as I go through each set of data. Does CFile not have a function that takes you to the end of the file in order to append the data or some kind of access rights that allow appending?
|
|
|
|
|
I'm tring to find a way to lookup a particular path in the DFS tree to find where the actual resource from what points to it.
I can't seem to find any API calls or objects which deal with this. The simple way is to pipe 'dfscmd.exe /view \\server\dfsshare /batch | grep path_feaure | awk '{print $4}'' and parse that output but it is ugly and I have to install dfscmd, grep and awk on each machine that needs this code.
Does anyone know where I can find some way to do lookups in a DFS tree programatically?
I know i can use NetShareGetInfo to find out if a path is a DFS root but that's as close as I've come (with a hour of google and msdn searches).
Any points in a relevant direction would be extremely helpful.
|
|
|
|
|
Sorry this post is from me and by DFS tree I mean (D)istributed (F)ile (S)ystem [not Depth First Search].
I forgot to login before I posted the message.
My apologies.
Sean
|
|
|
|
|
The article here is really great:
http://www.codeproject.com/listctrl/listeditor.asp
When I run the project and click on an edit box, the box
with focus looks like:
_ _
|________________|
The top part of the box is open and it looks funny. Any
chance any came across this and knows how to make it look
like a full box? Please, any response any one can give
me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
How about posting the question at the messageboard underneath the article you mentioned? At least, it has more relevancies.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I'm working on a frontend to an old dos program, and am at the point where i need to interact with the backend.
I was planning on using the System() call, but was wondering if there's a better way to interface with other programs. For instance, i'd like to know if the backend dos program is still running, or if the program has crashed.
Does VC++ provide a method to do this?
Thanks,
Mike
"I bet Einstein turned himself all sorts of colors before he invented the light bulb." -- Homer J.
|
|
|
|
|
Here is an example nicked from MSDN:
#include <windows.h>
#include <stdio.h>
#define MAXNAMELEN 255
#define CMDLINE "/c dir"
#define IMAGENAME "\\nt\\bin\\cmd.exe"
#define WINTITLE "CreateProcess DEMO"
main(){
BOOL fSuccess,fExit;
DWORD dwExitCode,dw;
STARTUPINFO SI;
PROCESS_INFORMATION pi;
HANDLE hProcess,hThread;
SI.cb =sizeof(STARTUPINFO); SI.lpReserved = NULL;SI.lpDesktop=NULL;
SI.lpTitle="CreateProcess DEMO";SI.cbReserved2=0;SI.lpReserved2=NULL;
fSuccess = CreateProcess((LPTSTR)IMAGENAME, (LPTSTR)CMDLINE,
(LPSECURITY_ATTRIBUTES)NULL,
(LPSECURITY_ATTRIBUTES)NULL,
(BOOL)TRUE,(DWORD)0,NULL,NULL,
(LPSTARTUPINFO)&SI,(LPPROCESS_INFORMATION)&pi);
if (fSuccess) {
hProcess = pi.hProcess; hThread = pi.hThread;
printf("Process Id = %d\nThread Id = %d\n",pi.dwProcessId,pi.dwThreadId);
dw = WaitForSingleObject(hProcess, INFINITE) ;
if (dw != 0xFFFFFFFF) {
fExit = GetExitCodeProcess(hProcess, &dwExitCode) ;
}
CloseHandle(hThread) ; CloseHandle(hProcess) ;
printf("COMPLETED!\n");
}
else printf("Failed to CreateProcess\n");
}
The same method can be used in a GUI-app as well.
|
|
|
|
|