|
Hi There!. I am a newcommer in MFC programming.
How does one parse parameters passed as command line arguments in the Win32 environment? I know i can use lpCmdLine, but how do i do that? Can someone show me an example. By the way I am useing Embedded Visual c++
|
|
|
|
|
The lpCmdLine parameter is an exact copy of the command line passed to your program, including all spaces, quote marks, etc. If you want to treat this as separate arguments, you must split it.
MFC supplies its own WinMain by default; however, you can override this if you wish. If you do so, call AfxWinInit to initialize MFC, and AfxWinTerm before returning. The MFC WinMain is implemented in winmain.cpp .
It's rare to do this. Typically, you instead override InitInstance in your class derived from CWinApp . You can then access the command line from CWinApp 's m_lpCmdLine parameter.
MFC offers the CCommandLineInfo class and the ParseCommandLine function for helping with command lines. To add support for your own options, create a new class which inherits CCommandLineInfo . Then override ParseParam .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks.
lpCmdLine is a unsigned short *.
The value i passed in the command line is just a BYTE (0-15). How can i convert lpCmdLine to a BYTE?
Gunnar
|
|
|
|
|
Whether the command line contained one byte or several dozen, lpCmdLine is accessed in the same manner for each. It's simply a pointer to the command-line arguments.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
How should the following be declared
class A
{
public:
B test;
};
class B
{
public:
A test;
};
I thought you just pre-declared class B before class A using the following line:
class B;
What am I doing wrong?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
You are declaring class A, that contains a member of class B, that contains a member of class A, that contains.....ad infinitum
Declare the test member as a pointer to class A or B.
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|
|
Beat me to it.. That's what you get when you are distracted before posting your reply
Ant.
|
|
|
|
|
It isn't the first case, when more people posted the same reply simultaneously. The simpler the question is, the more gurus answer
Robert-Antonio
"Czech Railways discovered, that in case of disaster the most damaged wagons
were the first and the last. So they decided to create trains without them."
|
|
|
|
|
You can only use forward declaration when using pointers.
Ant.
|
|
|
|
|
u can do it as:
class B;
class A
{
public:
B &test;
//or B *test;
};
class B
{
public:
A test;
};
|
|
|
|
|
hello all,
how shall i create a entry in registry using VC++.
i mean i need to add a key such that my application name shouldnt appear there. i mean there is an entry named "Extensions" in the registry and i need to create an entry {"Demo App"} in that. and then i need to add entries in the newly created.
but the problem with SetRegistryKey() is that it is creating the application name too. but i dont need it. how shall i do so.
ComputerNewton
|
|
|
|
|
int RegWriteKeyValue(HKEY hKeyParent,CString strPath,CString strKey,CString strVal)
{
CRegKey regKey;
DWORD dwKeyCreateMode=REG_OPENED_EXISTING_KEY;
long lRes;
lRes=regKey.Create(hKeyParent,strPath,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&dwKeyCreateMode);
if (lRes != ERROR_SUCCESS)
return 0;
lRes=regKey.SetValue(strVal,strKey);
if (lRes != ERROR_SUCCESS)
return 0;
// close the registry key
regKey.Close();
return 1;
}
RegWriteKeyValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce","Name","value");
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Thank u very much for ur help.
But it is in ATL. i dont want to use this in ATL.
once again thanks a lot. b'coz of ur reply i got an idea and i did it in SDK mixed with MFC to get my requirement.
Once again thank u very much.
ComputerNewton
|
|
|
|
|
use CRegKey of ATL classes.
God is Real, unless declared Integer.
|
|
|
|
|
Use the Win32 registry functions. Ugly, yes, but they work:
HKEY hNewKey = NULL;
DWORD disposition = 0;
DWORD error = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Extensions\\Demo App", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNewKey, &disposition);
char myString[] = "Some Data";
error = ::RegSetValueEx(hNewKey, "Some Value", NULL, REG_SZ, myString, sizeof(myString));
See MSDN on RegCreateKeyEx and RegSetValueEx for more info. (The code I provided is just a rough example... should compile and work but I can't be sure!)
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Hi
I'm working on a fairly large file indexing system, and I'm trying to find the best and fastest way of finding out if a file needs reindexing.
Currently the best we've got is keeping a DB of the last time a file was indexed and periodically rescanning a checking the last modifed date against that.
Is there a way of being told if a file has been created or modified, in a similar sort of way to Visual Studio bringing up the "This file has been modified outside of Visual Studio..." dialog? (One which doesn't require a lot of resources as well - this is intended to run in the background)
Cheers
Dave
|
|
|
|
|
Check out 'FindFirstChangeNotification' in the Win32 documentation.
Paul
|
|
|
|
|
Cheers Paul
It's always the problem with trying to find where to start looking!
Dave
|
|
|
|
|
you can look here also:
UINT ThreadNotifyFunc (LPVOID pParam)
{
HWND hwnd = (HWND) pParam; // Window to notify
HANDLE hChange = ::FindFirstChangeNotification (_T ("C:\\"),
TRUE, FILE_NOTIFY_CHANGE_FILE_NAME ¦ FILE_NOTIFY_CHANGE_DIR_NAME);
if (hChange == INVALID_HANDLE_VALUE) {
TRACE (_T ("Error: FindFirstChangeNotification failed\n"));
return (UINT) -1;
}
while (...) {
::WaitForSingleObject (hChange, INFINITE);
::PostMessage (hwnd, WM_USER_CHANGE_NOTIFY, 0, 2);
::FindNextChangeNotification (hChange); // Reset
}
::FindCloseChangeNotification (hChange);
return 0;
}
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Also look for ReadDirectoryChangesW() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
class a{
public:
a():rs(&db)
{}
CRecordset rs;//line a
CDatabase db; //line b
};
// my question is shld line b comes before line a
|
|
|
|
|
heu, you are trying to create an object, but you assign a member with another member of the same object, which wasn't set yet. so change your code...
i'd like to add a remark. your code is note very beautiful, and worse, it is not very useful.
put your data members in private statement, write your class definition in a .h file, and write the class implementation into a .cpp file :
A.h
<font style="color:blue;">class</font> CA {
CRecordset rs;
CDatabase db;
<font style="color:blue;">public:</font>
CA (<font style="color:blue;">void</font>);
<font style="color:green;">
}
A.cpp
CA::CA(<font style="color:blue;">void</font>) : rs(), db() {
}
<font style="color:green;">
TOXCCT >>> GEII power
|
|
|
|
|
i feel that was the most simple way to express his doubt.
It'd be funny to have .cpp and .h files along for such a simple question.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
anyway, his code was wrong !
and you, i'm waiting for your response at your "who's who" page...
thx
TOXCCT >>> GEII power
|
|
|
|
|
check out, its there!!
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|