|
cmd.exe has number of switches you have to use in order to make it execute a DOS command. For example:
cmd.exe /c dir
This will execute dir and will close dos window.
cmd.exe /k dir
This will execute dir and will dos window will remain open.
I hope this helps.
|
|
|
|
|
void CTestDirDlg::OnButton1()
{
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
startInfo.cb = sizeof(STARTUPINFO);
startInfo.lpReserved = NULL;
startInfo.lpTitle = NULL;
startInfo.lpDesktop = NULL;
startInfo.dwX = startInfo.dwY = startInfo.dwYSize = startInfo.dwXSize = 0;
startInfo.dwFlags = STARTF_USESHOWWINDOW;
startInfo.hStdInput = NULL;
startInfo.hStdOutput = NULL;
startInfo.hStdError = NULL;
startInfo.wShowWindow = SW_SHOW;
startInfo.lpReserved2 = NULL;
startInfo.cbReserved2 = NULL;
if (!CreateProcess ( NULL,
"c:\\command.com /k dir",
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&startInfo,
&procInfo
))
{
int err = GetLastError();
}
}
You can play with this a bit - the next thing to add is
the mechanism for passing the stdin, out, and error handles so that you can get the results...
|
|
|
|
|
#include <stdlib.h>
system("dir C:\\windows");
Bam, there ya go.
|
|
|
|
|
Does anybody know as how to migrate my projects from
visual C++ to Borland C++. Does Borland C++ builder include
Foundation Classes like MFC??
|
|
|
|
|
Yes, BCB 4 has what seems to be the version of MFC that shipped with VC 5.0 (may be updates), and can convert a VC 6 project.
I tried the Visual C++ Project Conversion Utility from the Tools menu, and converted a VC6 project (The Wizard2000 demo, available here) - or rather one build configuration.
The build balked only once, at #include <afxdtctl.h>, which is new to VC6.
You might be slightly better off moving the projects back
to VC5 before conversion - or at least setting the debug info settings back a notch to 'Program database' from 'Program database for edit and continue' but since (I think) you basically work with a single config in BCB this may not be an issue - you can edit these in BCB.
Tim
|
|
|
|
|
Does anybody knows about Borland C++ site just like "Code Tools".
I will appreciate response from readers
|
|
|
|
|
Hey James,
Why don't you talk to Chris about you starting one as part of CodeProject? (this site btw is codeproject.com)
I'm not a big Borland C++ guy, but I can't see how it would be that tough to open a forum for BC questions, and make a place to post BC code examples.
|
|
|
|
|
Adding a Borland C++ forum is a piece of cake - but how many people would use it?
|
|
|
|
|
In trying to manage PCH effectively on a large project and keeping track of and minimizing dependencies, I've often wanted a good tool for viewing the include tree of a file.
An ideal thing would be a add-in, you hit a button, it pops up a tree-view of the all included files (direct or indirect).
Anyone seen anything remotely like this?
-Philip
|
|
|
|
|
I know this is not what you are looking for, but might be a possible source of info.
I used the message pragma to instrument four headers of a simple dialog app with:
#if defined(SHOW_DEPENDANCIES)
#pragma message(" testDir.h included\n")
#endif
Then did a rebuild all -
Compiling resources...
Compiling...
StdAfx.cpp
stdafx.h included
Compiling...
TestDir.cpp
TestDirDlg.cpp
testDir.h included
resource.h included
TestDirDlg.h included
Generating Code...
testDir.h included
resource.h included
TestDirDlg.h included
Linking...
Seems to show that stdafx.h is included only once for all translation units, but the output seems staggered somehow... hmmm - perhaps compilation is multi-threaded in some way - maybe the preprocessor is spawned separately.
Would this effectvely track PCH usage during rebuilds?
You would think a compiler could offer some sort of 'verbose' switch to do this for us.
|
|
|
|
|
Your output is correct, because with PCH stdafx.h is read only once. There is no multi-threaded compilation, sadly, except in the sense the rest of MSDEV stays usable while you are compiling.
Your idea would be a start, but for a large project you need to represent the output as a tree somehow, not just a list of what is included, in order to make sense of it.
I saw some add-in that claimed to do this a while ago, and some of the "code browsers" claim to, but I've never gotten any of them to work for me.
-Philip
|
|
|
|
|
Hello gurus,
I am trying to develop a dll which will add a window to IE same as Web Search Assistant. Any ideas? I cant use Frames.
regards,
Mahesh
|
|
|
|
|
The web search assistant is a Deskband object that is registered under IE. You can create your own by implementing a COM object that supports IDeskband and a few other interfaces, or you can use the wizard I created under the ATL section of CodeProject for creating Deskbands.
Let me know if you have any development questions, I have done quite a few of these.
|
|
|
|
|
Can anyone tell me how to open a main menu programmatically?
In my main frame class of an MFC MDI app I have a function (OnMenuChar) that needs to mimic the functionality of pressing Alt-F on the keyboard to open the File menu. I don't want to do anything other than that, such as open a file, just open the menu so the user can then make their own choice.
I have tried several things to no avail. I can get the system menu to open, but not the main menu.
Thanks in advance for any assistance!
Jim
|
|
|
|
|
Did you try HiliteMenuItem() function?
|
|
|
|
|
You can try the following
/* Pass the handle to the window
SetForegroundWindow(hwnd)
// Pass alt- f
keybd_event(VK_MENU,0,0,0);
keybd_event('F',0,0,0);
// Release alt
keybd_event (VK_MENU, 0,KEYEVENTF_KEYUP ,0)
Regards,
Renga.
|
|
|
|
|
i founded out that the CListCtrl class has a big big bug.
I inserted only one item without subitems in that way:
// CListCtrl e.g. OnMouseClick.....
LV_ITEM lv;
lv.mask ...... and so on
lv.iItem = 0;
lv.iSubItem = 0;
rc = InsertItem( &lv );
SetItemData( rc, (long)bitmask );
so the items will be inserted but the item data will be not
the same i have inserted. it will be every time i debug it
for the next item....
e.g.
normal:
item itemdata
0 123
1 321
2 132
3 213
not normal:
item itemdata
0 321
1 132
2 213
3 123
that's very bad...
but i solved it in this way...
i deselect the sort entry in the resource workshop....
note: you don't have any sort ( ascend / descend )
right is: none
best regards
ingo eberhardt
NOTE: plz do not send me any spam mails or advert.
|
|
|
|
|
I wrote a program that simulate Brower upload file to Web Server.This Program run well in the local network,But it is fail When it connect to outside Web Site through Local Proxy server.Proxy server send the program a response message,The status code of response message is 407.
I found that if i use the HttpSendRequestEx Function of wininet.dll then proxy can response 407 status code ,if i use the HttpSendRequest function of wininet.dll then proxy accept this request.I don't know what happen about it!
Who can tell me how to the solution of this issue!
Let me can use the HttpSendRequestEx funtion of wininet.dll
upload file to web server,But proxy cann't send 407 status code.
or
Tell me how to use the HttpSendRequest function of wininet.dll writeing a upload file program
Thanks you!
|
|
|
|
|
I'm trying to implement a FTP client application. This FTP client will list the remote directory on its left pane in a tree view, which derived from CTreeView class and its sub directories or files will be listed on right pane in a list view, which derived from CListiew class.
In my application, i used CInternetSession class to handle the protocol and the CFTPConnection class for the connection.
However, i'm fail to connect to any FTP server!
I'm happy to receive any comments and advices from you!
|
|
|
|
|
#include <afx.h>
#include <afxwin.h>
#include <afxinet.h> //this is the good stuff
#include <stdio.h>
// compile for release with
// cl /MT /GX
// or for debug with
// cl /MTd /GX
CWinApp theApp;
void main()
{
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// catastropic error! MFC can't initialize
return;
}
// create a session object to initialize WININET library
// Default parameters mean the access method in the registry
// (that is, set by the "Internet" icon in the Control Panel
// will be used.
CInternetSession sess(_T("MyProgram/1.0"));
CFtpConnection* pConnect = NULL;
try
{
// Request a connection to ftp.microsoft.com. Default
// parameters mean that we'll try with username = ANONYMOUS
// and password set to the machine name @ domain name
pConnect = sess.GetFtpConnection(_T("ftp.microsoft.com"));
// use a file find object to enumerate files
CFtpFileFind finder(pConnect);
// start looping
BOOL bWorking = finder.FindFile(_T("*"));
while (bWorking)
{
bWorking = finder.FindNextFile();
printf("%s\n", (LPCTSTR) finder.GetFileURL());
}
}
catch (CInternetException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
printf("ERROR! %s\n", sz);
pEx->Delete();
}
// if the connection is open, close it
if (pConnect != NULL)
pConnect->Close();
delete pConnect;
return;
}
|
|
|
|
|
hi, below was my sample coding for my application
//this is my InetSession
m_pInetSession = new CInternetSession(
NULL, 1,
PRE_CONFIG_INTERNET_ACCESS );
// If the CInternetSession object didn't
// allocate, bail out.
if(m_pInetSession == NULL ){
return( 0 );
}
//ftp connection
m_pFtpConnection = m_pInetSession->GetFtpConnection(
"127.0.0.1", "", "");
what i did here is i m running an ftp server on my local host. The ftp server is a shareware program that will enable any ftp client connect to u local host without networking environment. i did try to connect to my local host by using FTP explorer shareware. its works fine. i just want to prove that my ftp server shareware is working fine. Next, i try to compile n run my application, the results were, the first was ok, but when i try to run on the second time its failed. i also try to run my application on a network environment, it was failed too !
I did refer to the MSDN FTPTREE sample program, its works fine. i try to copy out some part of the code to my application, but it was fail!
I totally have no idea what to do next, please HELP !!!
Thanks !
|
|
|
|
|
Hi
Just a guess as to why your copied and pasted code
doesn't work !
Have you made sure you statically linked your code correctly, eg included uuid.lib in
Project->Settings->Link->Object/Library modules "uuid.lib "
Its a common problem
Regardz
Colin Davies
|
|
|
|
|
if (!AfxParseURL(strFtpSite, dwServiceType, strServerName, strObject, nPort))
{
// try adding the "ftp://" protocol
CString strFtpURL = _T("ftp://");
strFtpURL += strFtpSite;
if (!AfxParseURL(strFtpURL, dwServiceType, strServerName, strObject, nPort))
{
AfxMessageBox("IDS_INVALID_URL", MB_OK);
return;
}
}
hi,
i managed to solve this problem. Just add the above code right after the InteenetSession, then it will work fine.
I ve tried it out!
|
|
|
|
|
if (!AfxParseURL(strFtpSite, dwServiceType, strServerName, strObject, nPort))
{
// try adding the "ftp://" protocol
CString strFtpURL = _T("ftp://");
strFtpURL += strFtpSite;
if (!AfxParseURL(strFtpURL, dwServiceType, strServerName, strObject, nPort))
{
AfxMessageBox("IDS_INVALID_URL", MB_OK);
return;
}
}
hi,
i managed to solve this problem. Just add the above code right after the InteenetSession, then it will work fine.
I ve tried it out!
|
|
|
|
|
if (!AfxParseURL(strFtpSite, dwServiceType, strServerName, strObject, nPort))
{
// try adding the "ftp://" protocol
CString strFtpURL = _T("ftp://");
strFtpURL += strFtpSite;
if (!AfxParseURL(strFtpURL, dwServiceType, strServerName, strObject, nPort))
{
AfxMessageBox("IDS_INVALID_URL", MB_OK);
return;
}
}
hi,
i managed to solve this problem. Just add the above code right after the InteenetSession, then it will work fine.
I ve tried it out!
|
|
|
|
|