im using Process::start("test.exe","ture");
it start a process called test.exe and send argument ture but on text.exe i don't know how to get the argument that have been sent,test.exe is win32 window. all i need help with how to get the ture in test.exe?
follow the example if it is a console application -
int _tmain(int argc, _TCHAR* argv[])
-
{
-
int i;
-
for(i=0;i<argc;i++)
-
{
-
wprintf(L"%s",argv[i]);
-
}
-
return 0;
-
}
-
If this is an window application -
#include "stdafx.h"
-
#include "argument.h"
-
-
-
int APIENTRY _tWinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPTSTR lpCmdLine,
-
int nCmdShow)
-
{
-
MessageBox(NULL,lpCmdLine,L"Command Line argument",MB_OK);
-
return 1;
-
}
-
10 6029
follow the example if it is a console application -
int _tmain(int argc, _TCHAR* argv[])
-
{
-
int i;
-
for(i=0;i<argc;i++)
-
{
-
wprintf(L"%s",argv[i]);
-
}
-
return 0;
-
}
-
If this is an window application -
#include "stdafx.h"
-
#include "argument.h"
-
-
-
int APIENTRY _tWinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPTSTR lpCmdLine,
-
int nCmdShow)
-
{
-
MessageBox(NULL,lpCmdLine,L"Command Line argument",MB_OK);
-
return 1;
-
}
-
MessageBox(NULL,lpCmdLine,L"Command Line argument",MB_OK);
will this have the ture value?
will this have the ture value?
why dont you try it and see for yourself?
i would if i can go on my laptop my mom is using it but i will and i tell you the result thanks very much for your time
i tried it and it worked just fine thanks very much
can you help me with this one please. ok since the LPTSTR lpCmdLine is declared in WinMain i used this to create var to store ipcmdline value, LPTSTR args = lpCmdLine;i put it in WinMain but when i try to call it from a different function it says undifined args i know why it is saying that but if i decalre the varabile in the other function ill get a different error. so is there way i can call the varable(args) in winMain funtion ?
I have no clue what are you talking about. Can you please post code?
ok - // Take and Run.cpp : Defines the entry point for the application.
-
//
-
-
#include "stdafx.h"
-
#include "Take and Run.h"
-
#include <string>
-
#include <objidl.h>
-
#include <gdiplus.h>
-
using namespace Gdiplus;
-
#pragma comment (lib,"Gdiplus.lib")
-
-
-
#define MAX_LOADSTRING 100
-
-
// Global Variables:
-
HINSTANCE hInst; // current instance
-
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
-
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
-
-
// Forward declarations of functions included in this code module:
-
ATOM MyRegisterClass(HINSTANCE hInstance);
-
BOOL InitInstance(HINSTANCE, int);
-
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
-
-
VOID onPaint(HDC hdc)
-
{
-
Graphics graphics(hdc);
-
Pen pen(Color(255, 0, 0, 255));
-
graphics.DrawLine(&pen, 0, 0, 200, 100);
-
}
-
-
int APIENTRY _tWinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPTSTR lpCmdLine,
-
int nCmdShow)
-
{
-
UNREFERENCED_PARAMETER(hPrevInstance);
-
UNREFERENCED_PARAMETER(lpCmdLine);
-
-
// TODO: Place code here.
-
// THE VARABILE THAT WILL STORE THE IPCMDLINE VALUE
-
LPTSTR args = lpCmdLine;
-
-
MSG msg;
-
HACCEL hAccelTable;
-
-
GdiplusStartupInput gdiplusStartupInput;
-
ULONG_PTR gdiplusToken;
-
-
// Initialize GDI+.
-
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
-
-
// Initialize global strings
-
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
-
LoadString(hInstance, IDC_TAKEANDRUN, szWindowClass, MAX_LOADSTRING);
-
MyRegisterClass(hInstance);
-
-
// Perform application initialization:
-
if (!InitInstance (hInstance, nCmdShow))
-
{
-
return FALSE;
-
}
-
-
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TAKEANDRUN));
-
-
// Main message loop:
-
while (GetMessage(&msg, NULL, 0, 0))
-
{
-
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
-
{
-
TranslateMessage(&msg);
-
DispatchMessage(&msg);
-
}
-
}
-
GdiplusShutdown(gdiplusToken);
-
return (int) msg.wParam;
-
}
-
-
-
-
//
-
// FUNCTION: MyRegisterClass()
-
//
-
// PURPOSE: Registers the window class.
-
//
-
// COMMENTS:
-
//
-
// This function and its usage are only necessary if you want this code
-
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
-
// function that was added to Windows 95. It is important to call this function
-
// so that the application will get 'well formed' small icons associated
-
// with it.
-
//
-
ATOM MyRegisterClass(HINSTANCE hInstance)
-
{
-
WNDCLASSEX wcex;
-
-
wcex.cbSize = sizeof(WNDCLASSEX);
-
-
wcex.style = CS_HREDRAW | CS_VREDRAW;
-
wcex.lpfnWndProc = WndProc;
-
wcex.cbClsExtra = 0;
-
wcex.cbWndExtra = 0;
-
wcex.hInstance = hInstance;
-
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TAKEANDRUN));
-
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
-
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
-
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TAKEANDRUN);
-
wcex.lpszClassName = szWindowClass;
-
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
-
-
return RegisterClassEx(&wcex);
-
}
-
-
//
-
// FUNCTION: InitInstance(HINSTANCE, int)
-
//
-
// PURPOSE: Saves instance handle and creates main window
-
//
-
// COMMENTS:
-
//
-
// In this function, we save the instance handle in a global variable and
-
// create and display the main program window.
-
//
-
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
-
{
-
HWND hWnd;
-
-
hInst = hInstance; // Store instance handle in our global variable
-
-
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
-
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
-
-
if (!hWnd)
-
{
-
return FALSE;
-
}
-
-
ShowWindow(hWnd, nCmdShow);
-
UpdateWindow(hWnd);
-
-
return TRUE;
-
}
-
-
//
-
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
-
//
-
// PURPOSE: Processes messages for the main window.
-
//
-
// WM_COMMAND - process the application menu
-
// WM_PAINT - Paint the main window
-
// WM_DESTROY - post a quit message and return
-
//
-
//
-
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LPTSTR lpCmdLine)
-
{
-
int wmId, wmEvent;
-
PAINTSTRUCT ps;
-
HDC hdc;
-
-
switch (message)
-
{
-
case WM_COMMAND:
-
wmId = LOWORD(wParam);
-
wmEvent = HIWORD(wParam);
-
// Parse the menu selections:
-
switch (wmId)
-
{
-
case IDM_about:
-
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
-
break;
-
case IDM_EXIT:
-
DestroyWindow(hWnd);
-
break;
-
default:
-
return DefWindowProc(hWnd, message, wParam, lParam);
-
}
-
break;
-
case WM_PAINT:
-
hdc = BeginPaint(hWnd, &ps);
-
// HERE I USED THE ARGS VARABILE AND I GET A ERROR THAT SAYS ARGS UNDIFINED IF I MOVE MESSAGBOX(..); TO WINMAIN FUNCTION IT WILL WORK
-
MessageBox(NULL,args,L"Command Line argument",MB_OK);
-
EndPaint(hWnd, &ps);
-
break;
-
case WM_DESTROY:
-
PostQuitMessage(0);
-
break;
-
default:
-
return DefWindowProc(hWnd, message, wParam, lParam);
-
}
-
return 0;
-
}
-
-
// Message handler for about box.
-
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-
{
-
UNREFERENCED_PARAMETER(lParam);
-
switch (message)
-
{
-
case WM_INITDIALOG:
-
return (INT_PTR)TRUE;
-
-
case WM_COMMAND:
-
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
-
{
-
EndDialog(hDlg, LOWORD(wParam));
-
return (INT_PTR)TRUE;
-
}
-
break;
-
}
-
return (INT_PTR)FALSE;
-
}
-
i declared the varabile in line 43 and i used messagebox in line 183
OK,
The issue is you need to understand the grammatical rules and structure of c/c++.
You have defined args in _tWinMain. So args is a local variable to for _tWinMain
But you are trying to access this variable from your WndProc which is a different function. So an obvious compiler error is generating.
Your problems solution can be taken from your own source code. Take a look at hInstance variable in _tWinMain this is a local variable. But to access this data from WndProc, you(automated system of visual studio IDE) have defined a global variable name hInst outside main. and then hInst is being accessed from WndProc. So, you can define your args globally. and Dont create message alert from your WM_PAINT
greate it worked and i was creating message because it was the simple way that it would show me if it works
Sign in to post your reply or Sign up for a free account.
Similar topics
by: d davis |
last post by:
I realize that I am getting way ahead of myself. I am studying Learning Perl
Win32, Programming Perl and Mastering Perl Tk.
For a practical example that I can see that works doing something that I...
|
by: Andrew Warren |
last post by:
When I build my winforms exe using the IDE I have a
perfectly functioning exe. If I try to build the same
project using the .Net Framework csc compiler I get a
seemingly valid exe produced...
|
by: Lubo¹ ©lapák |
last post by:
Hi,
i have a Win32 application in CSharp and i have to run command "net send
....." (these is a command for windows command-line) from this application,
but i don't know how can i run this...
|
by: David A. Osborn |
last post by:
I am current writing a console program that takes two file paths as command
line input. I get the command line input using the following code:
parameter = Split(Command())
input = parameter(0)...
|
by: Bit byte |
last post by:
I have a project that I normally build (without problems) from the
DevStudio IDE. However, I have embarked on automating all my builds
(this test project being one of several).
The project...
|
by: Selva Chinnasamy |
last post by:
Hi I have a Windows application written in VB which has many functions. In
addition it also reads a database and generates a output file.
Currently this function is called when ever user clicks...
|
by: wxforecaster |
last post by:
As alluded to in my post yesterday, I'm trying to compile a common C utility
in Windows.
It's only reference is to zlib.h, which needs zconf.h and in turn libz.a
On Unix I've compiled this with...
|
by: futnuh |
last post by:
I am having exactly the same issue as this poster back in 2005.
It's strange behaviour where libraries are being automatically appended to my "additional dependencies". In the following linker...
|
by: wangzq |
last post by:
Hello,
I'm passing command line parameters to my browser, I need to pass the
complete command line as-is, for example:
test.py "abc def" xyz
If I use ' '.join(sys.argv), then the double...
|
by: =?Utf-8?B?UmFtb24gR2VuZQ==?= |
last post by:
Hello:
I am building a console application and I am having an issue with the
command line arguments. A couple of my arguments are paths and they are
usually enclosed in double quotes. If one of...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |