|
Use these Api's
Most Simpler One
-->WinExec()
--->ShellExecute
Little Tough
->CreateProcess
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
You can use ShellExecute(handle, "open", "File name with path", NULL, NULL, SW_SHOWNORMAL); to open othe application. for eg "path+notepad.exe"
|
|
|
|
|
Does anyone have a suggestion on where I can take a Online programming class? Thanks for anyfeedback.
|
|
|
|
|
I am trying to read a text file that is in the same directory as the program. As I am reading it in, I need to edit some of it and put the text from the text file and the edit into an edit box. I am somewhat new to Visual C++. Can someone Help me out?
Thanks in advance for your help!
Chris
|
|
|
|
|
To get you started; search for CStdioFile in the MSDN library. Of course, you can read a text file using basic file streams as well. But if you implementing an MFC application then using CStdioFile will simplify your efforts. You simply construct an object of this type (CStdioFile is a class type). Read the documentation in the MSDN on how to construct it. There are two very basic functions; ReadString and WriteString. It will read the file line by line and fill a null terminated string. Use a CString or std::string or _TCHAR[SIZE] array, or whatever it is you use to process strings. Read up on CString if you aren't familiar with that. Basically, MFC provides some very simple interfaces for doing what you are doing. Obviously, you'll have to write the C++ code to manipulate the strings as you read them but the CStdioFile should make the file I/O pretty simple. There are many ways to get data into an edit control; I assume you already know how to do that part once you have manipulated the data you've read from the file.
Regards,
Shawn
|
|
|
|
|
As has been pointed out, MFC offers some classes to do this. The other option is the standard ifstream/ofstream classes. I have written articles on these on Code Project, you should check both out before deciding which to use.
If you learn to use streams, they will be useful to you in any C++ setting. However, I'm not familiar enough with the MFC alternatives to know if they have significant other benefits.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm trying to port some code I wrote using DirectSound in C# to Visual C++ (managed). I've got most of it done except for this problem I'm stuck at. I understand that this is a newbie question, so please be gentle
The function I'm having a problem with is CaptureBufferObject->Read(arguments) in C++.
In C#, the function protoype is:
public Array Read(
int bufferStartingLocation,
Type returnedDataType,
LockFlag flag,
int[] ranks
);
My code has the following usage of the Read method.
MemBuffShort = (short[])(StreamCaptureBuffer.Read(StreamCapBuffReadPos, typeof(short), LockFlag.None, 50000));
where MemBuffShort = new short[100000];
In C++, the function prototype is:
public: Array* Read(
int bufferStartingLocation,
Type *returnedDataType,
LockFlag flag,
int ranks __gc[]
);
My problem is with the last parameter: int ranks __gc[]
I tried the following:
static System::Int32 CapBuffPara[] = new System::Int32[] { 50000 };
MemBuff = StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara);
However, I get the following error message:
error C2440: '=' : cannot convert from 'System::Array __gc *' to 'int __gc[]'
How do I solve this problem? What needs to be changed?
Thanks for your help!
|
|
|
|
|
Well, since no one is going to tackle this extremely hard problem, here is the answer.
Instead of the line int rank __gc[], try either int rank[] or int *rank.
Bottom line, the C# line "int[] rank" defines an array of integers. The line "int rank __gc[]" wants to recast __gc[] from the class System::Array to an int array, and it won't work. Either "int rank[]" or "int *rank" define an array of integers.
Geez, people, at least pretend to read the books or understand what the definitions of things are.
|
|
|
|
|
The function definition (or should I call it "protoype") was specified in the DirectX SDK, so I can't change it. In C#, the argument reuqired was just an integer. In the C++ implementation, it requires an array of a maximum of 3 elements.
|
|
|
|
|
|
Hey Anonymous... thanks for the reply! I know that this is a very elementary problem, but I'm new to programming in C++ and learning.
I figured out the mistake I was making... I forgot the (System::Int32[]) typecast for MemBuff.
MemBuff = (System::Int32)(StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara));
|
|
|
|
|
Hi,
I am trying to make this:
template<int i="">
void func(char* &c){
c+=i;
}
class Cqq
{
void (*m_ququ)(char* &c);
Cqq(bool b)
{
if(b)
m_ququ=func<1>;
else
m_ququ=func<2>;
}
};
in Visual 6.0 and receive a compilation error.
Any ideas?
Thanx
magicAL
|
|
|
|
|
What was the error? Which line was it on?
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"
|
|
|
|
|
I can ShellExecute a rich text format file, but it always
opens in Word. I can change the registry and try to make
the rtf file execute into Wordpad or Wordperfect, but is
there any easier way to ShellExecute a rtf file into a
different processor? Im not really sure how I can programmatically find the Wordperfect executable.
Sincerely,
Danielle Brina
|
|
|
|
|
ShellExecute(NULL,"open", "wordpad.exe", "c:\file.rtf", NULL, SW_SHOWNORMAL);
or
ShellExecute(NULL,"open", "wordpad.exe c:\file.rtf", NULL, NULL, SW_SHOWNORMAL);
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I wrote a program that have some classes one for dialog one for app and on class that drives from CWinThread class
and also one class that represet TCP conection
in this class that create in the CWinApp class not in thread my OReceive never be called
can some one help me??
|
|
|
|
|
I have a Visual C++ 6.0 program which needs to capture the client area bitmap from the window of another running application. I have the window handle of the target window and am able to get the bitmap if the target window is completely visible, but if the window is partially overlayed, then the bitmap capture gets the overlaying windows as well. I have read here and other sites that sending a WM_PRINT message to the target window and providing a device context will do this, but so far I have been unable to get this to work. The code I am using is the following:
-----------------------------------------------------------------------------------------
CRect rect;
CDC memDC;
CWnd* pWindow = CWnd::FromHandle( m_hWindow );
if ( ( pWindow != NULL ) && ( IsWindow( pWindow->m_hWnd ) == TRUE ) )
{
CDC* pClientDC = new CClientDC( pWindow );
CBitmap* pBitmap = new CBitmap();
pWindow->GetClientRect( &rect );
pBitmap->CreateCompatibleBitmap( pClientDC, rect.Width(), rect.Height() );
memDC.CreateCompatibleDC( pClientDC );
CBitmap* pOldBitmap = memDC.SelectObject( pBitmap );
// Adding this line and removing the next line did not work
//SendMessage( m_hWindow, WM_PRINT, ( WPARAM )memDC.GetSafeHdc(), PRF_CLIENT );
// This code captures the overlayed windows
memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pClientDC, 0, 0, SRCCOPY );
memDC.SelectObject( pOldBitmap );
ReleaseDC( m_hWindow, pClientDC->GetSafeHdc() );
delete pClientDC;
}
-----------------------------------------------------------------------------------------
What do I need to modify in this code so that the target window bitmap is captured even if the window is partially overlayed.
|
|
|
|
|
there is another command u can send too ... i cant remember what it is right now sorry (*scratches head*)
also there is always the possibility that the app in question doesnt handle that message so u cant print it that way
"there is no spoon" biz stuff about me
|
|
|
|
|
why ? are you ashamed ? ( this is a joke ! )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Try one of the available packers on the net (or write your own).
But know that "There's always a crack, that's how the light gets in"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have a app that needs to read and write stuff to the reg, I have my custom Reg functions in a seperate CPP file "RegHelpers.cpp" along with a header file "RegHelpers.h".
If I uncomment these 2 lines it gives a "unresolved external symbol" error for the functions in "RegHelpers.h"
//#define _UNICODE
//#define UNICODE
#include <windows.h>
#include <tchar.h>
#include "resource.h"
#include "RegHelpers.h"
I can not figure out what the problem is!!!
To make my program fully Unicode don't I need to change some Preprocessor settings?
Also, I used to use strings like this all the time:
LPSTR String = new char[256];
then I learnt about unicode, so I started doing them this way:
PTCHAR String = new TCHAR[256];
Do I need to do "new TCHAR[256 * sizeof(TCHAR)];"?
Also should I change them from PTCHAR to LPTSTR?
Do I really need to use the new operator on my strings?
Haha I'm really starting to hate data types.
wWw.KruncherInc.cOm
|
|
|
|
|
have u changed the program entry point in the project settings?
"there is no spoon" biz stuff about me
|
|
|
|
|
Yeah I was going to do that, but I couldn't find where to do it at.
wWw.KruncherInc.cOm
|
|
|
|
|
KingKruncher wrote:
If I uncomment these 2 lines it gives a "unresolved external symbol" error for the functions in "RegHelpers.h"
You haven't really given enough information, but... Is RegHelpers.cpp compiled into a library? And if so, was the library also compiled for Unicode? If not, you'll get these errors. If it's not a library, does the header file use TCHAR and the cpp file use char ? This will also cause these linker errors only for Unicode builds. Other than that, you'll have to give a bit more information.
KingKruncher wrote:
Do I need to do "new TCHAR[256 * sizeof(TCHAR)];"?
No. The [] verison of new allocates multiples of the data size, so new TCHAR[256] allocates 256 bytes for non-unicode builds and 512 bytes for unicode builds.
KingKruncher wrote:
Also should I change them from PTCHAR to LPTSTR?
It doesn't really matter - they are defined the same. Personally, I use PTCHAR for variables that are intended to point to a single character, and LPTSTR for variables that are a string, as that is what the names suggest.
KingKruncher wrote:
Do I really need to use the new operator on my strings?
You could allocate them on the stack like any other array, but if you need them to persist beyond a single function, then use new .
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"
|
|
|
|
|
I don't want the Afx... Strings to be shown when the program is Spyed i.e i don't want any one to know my program was made using MFC is there a way???
|
|
|
|