|
Hi,
I forgot to mention that I'll be piping information to/from the child process. I seem to remember there was some reason for choosing CreateProcess over ShellExecute. Will the program inherit the pipe handles?
Thanks,
Mike
|
|
|
|
|
Yes, use a thread and rerurn a handle.
PJ and Dr. N both have good articles on these.
PJ. www.naughter.com
and Dr. N www.flounder.com
P.J. example is in popwatch
Dr. N's is called worker threads I believe..?
Anyway create a handle
HANDLE myproject::StartShell(blah,blah,blah){
ShellExecute or CreatePro
return hwnd;
}
CP has a good artice also called A newbie's elementary guide to spawning processes.
Nishant does a good job, but does not go into the depth of the articles above.
Dr. N. is hard to read, but once you understand him he provides great info on both these subjects.
A good article appeared in March 1998 in MSDN Journal.
"Extend the Windows 95 Shell with Application Desktop Toolbars "
Notice how they managed the threads both worker and UI.
Also look at blade and the many win UI's that shell it. Notice they have setup two way communication between the com object and the UI.
Most all rippers include blade as the workhorse.
Also WinLame uses two way between the GUI and the com obj (LAME)
Another option is to create Custom Messages and post them. In your child process trap em in the default process and extract the params.
You may also create a defwinpro in the spawner and trap message back from the child app.
Remem to create a header with the defines and include it in both apps.
pcode:
#define my_message ((WIN_USER)+1024);
CStringArray message;
Message.SetSize(0,1999);
message.Add(2,"please insert new disk into drive A:")
...
message.Add(99,"Please remove disk from drive A:");
...
PostMessage(my_message,0,99);
= Remove disk from drive A:
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
MFC is confusing to me. Can someone explain how I insert any class of my own into a MFC "skeleton" program and then have the data my class(s) contain displayed and save.
I'mm new to MFC especially the Doc/View stuff.
C++ is my favorite programming language
|
|
|
|
|
|
Oi guys, trying to create a simple calendar and have 42 static text boxes with names box_1 through box_42. How can I increment from one box to another(lets say go from box_1 to box_2 ) inside a for loop, becasue I need to change the text to the corresponding number of days in the month, so the boxes are going to change depending on what month and or year it is.
ex: first day of month starts on tuesday so box_3 needs to have the text in it be 1, so I want a for loop that will continue changing the text of each one until we run out of days in the month
something like this
for(int N = 1 ; N < days_in_month ; N++)
{
box_N.dlgText = N
}
I know this is pretty low level stuff, but I havent used MFC in a long time and I'm stumped lol
Thanks
Pete
|
|
|
|
|
I would make sure the static text boxes have consecutive IDs, and access them via GetDlgItem() calls
for (int N = FIRST_ID, N <= LAST_ID, ++N)
{
GetDlgItem(N)->SetWindowText
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I'm looking for some SNMP code examples... just somthing straight forward, in C++/MFC ... I have found many pre-compiled libs, and some COM stuff... but I'm interested is just some Plain C++ or MFC code....
Anyone want to share some bookmarks ?
qcha0s
|
|
|
|
|
Hi
MSDN has some sample of Simple Network Management Protocol SnmpUtil and Testdll.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpsnmp.asp
Guess you know about these, pleaase also serch for a company called logiair as they were building a compiler for had completed a couple of libs.
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
soruceforge.net has many programs. just type SNMP in the search box and start looking.
Watch the license though, some of it is GPL which you cannot copy.
|
|
|
|
|
Hello,
I wrote an appli in VC++ that interfaces a database MySQL to store my data, both are linked by ODBC.
I would like to avoid to make too many costly DB extractions in my DB to fill a list, I would like to verify if my DB table content has been modified till last extraction.
Looking at MySQL doc, I found the request "SHOW TABLE STATUS LIKE 'Clients'" that returns a certain numbre of infos on the table and, in particular, the date/time of last update.
But, I have no idea on the way to launch this request from VC++ and retrieve the infos.
Hereunder is what I usually do to send my requestes (i.e. for a select):
---------------------------------------------
DBName = GlobalDSNIGS + ";UID=;PWD:";
res = "SELECT CleClients,CL_Lastname,CL_Firstname from Clients WHERE (CleClients > 0)";
gDB.OpenEx(DBName,CDatabase::noOdbcDialog);
TRY
{
rs.Open( CRecordset::forwardOnly, res );
NbRecord = rs.GetRecordCount();
}
CATCH(CDBException, e)
{
ErrMsg ="**ERR: "+e->m_strError;
}
END_CATCH
if ((ErrMsg == "") && (NbRecord > 0)){
while(!rs.IsEOF()) {
rs.GetFieldValue( "CleClients", Nbr);
rs.GetFieldValue( "CL_Lastname", Lastname);
rs.GetFieldValue( "CL_Firstname", Firstname);
ID = BLANK.Left(10-strlen(Nbr)) + Nbr; // justify on 10 char
// m_GuestsList.AddString(Lastname + "-" +Firstname+" / Guest# : "+ID);
rs.MoveNext();
}
}
rs.Close();
gDB.Close();
-------------------------------------------------------------
Is there a way to do this or even onother way to retrieve this last date/time infos?
Thanks in advance for you answer
DD
|
|
|
|
|
Hi all,
As I know that CDialog is a MFC class. And I looked in MSDN to find its destructor and constructor. I really don't know when CDialog is destroyed by a destructor? Does it has its own destructor? When I used the method CDialog::OnOK or CDialog::OnCancel(), is it a way to call CDialog's destructor?
By the way, in VC++ or C++, is there a garbage collector like there is in Java? I wonder why Java can do what VC++ can without pointer.
What are the advantages and disvantages of pointer?
What is the most dangerous thing you have to be aware of when trying to use pointer?
Why VC++ program usually gets runtime error? Is it because of pointer?
Thanks for reading!
|
|
|
|
|
that's a boat load of questions ...
1- CDialog receives a message ( WM_DESTROY or something like that ) when it's destroyed. The problem with dialogs, is that it must be destroyed from within, when the user clicks on ok, it will call EndDialog, which will do a bit of cleaning. MSDN has a lot of good documentation on the Life Cycle of a Dialog Box .
2- I don't know Java, maybe them implement pointers, but are hidden from the user; and only handled by the memory manager ( and garbage collector ).
3- pointers dis/advantages .. both have their use, pointers, are easier to use when passing information to functions and methods, if not using pointers, and passing a class to a function by value the class will be copied, a loss of time and memory. There are tons of other examples this ... google for it.
4- pointers can be NULL ...
5-yes, sometimes, but mostly for bad memory management and handling.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks. I got your ideas.
But you know, in my project, I can get the value of a public member variable of a dialog after I click Ok or Cancel (I means, at that time, the dialog disappears). If WM_DESTROY message really destroys CDialog object then how come I can get the value of its public member variable?
Example:
When I want to confirm the user when he/she deletes something by showing a confirmation message. If the user clicks Ok when the user confirms that he/she intentionally deletes, and clicks Cancel when the user rethinks not to delete.
bool m_bPressed; // get the status of the confirmation dlg
CConfirmDlg dlg;
dlg.DoModal();
m_bPressed = dlg.m_bAgree; //m_bAgree is the member variable of
//CConfirmDlg which indicates Ok or Cancel button is pressed
if (m_bPressed) // user clicks OK
//do something
else //user clicks Cancel..
//do something
Thanks for reading!
|
|
|
|
|
(my bad )
WM_DESTROY destroy the dialog "window", not the dialog class.
in your example, the dialog class will be created when the variable in instanciated, the dialog "window will be created at the DoModal call.
the dialog "window" will be destroyed when the DoModal finish, and the class will be deleted when the variable goes out of scope.
that's one reason you cannot access UI controls of your dialog before the dialog "window" is created; or after it is destroyed.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks, it's clear enough. But I don't really understand what you meaned "out of scope". So when object of CDialog is totally destroyed (not its "window")?
Thanks for reading!
|
|
|
|
|
"out of scope" ... basic C/C++ concept.
when you declare a variable on the stack in a function ( or withing {...} the variable is deallocated and "destroyed" when the it leaves the current scope ( either the end of the function or the matching } .
for example (on the stack):
void SomeClass::SomeFunction()
{
AnotherClass myClass;
}
on the heap :
void SomeClass::AnotherFunction()
{
AnotherClass* pMyClass = NULL;
pMyClass = new AnotherClass;
delete pMyClass;
}
So to answer you question, the CDialog object will be destructed at the end of the function.
void SomeClass::YetAnotherFunction()
{
CDialog dlg;
dlg.DoModal();
}
or
void SomeClass::YetAnotherFunction2()
{
CDialog* pDlg;
pDlg = new CDialog;
pDlg->Create( );
pDlg->ShowWindow(SW_SHOW);
delete pDlg;
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
WIN Management WMI Service (64 bit env on IA-64) doesn't seem to load 32 bit dlls (don't know why).
We have confirmed this by removing load call for 32 bit dll, after removing this call, it works fine.
Need to find some solution as we can not have 64 bit version of that dll. Or do we have to some setting
to load it.
Please let us know if anyone has any idea
Thanks and Regards
Deepak
|
|
|
|
|
did you try using the dll help loader?..
Sovled my beta issue.
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
Do not know about it, What is that, please elaborate
|
|
|
|
|
When I load a 16 on the 64 I use
HINSTANCE hLiba = LoadLibrary( "dbghelp.dll" );
before loading.
Best Wishes and write anytime,
Marty
Ps. This helps with the no insertsion point in early dll's.
Pls. remem to check load with hLiba.
I got this from an article by Zifrim at cg.
Also Dr. N did some work with 16 ast http://flounder.com/
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
Hello,
Yes, it is so, but there is a reserved area for such as this. Thunking is the problem. By default, 64-bit applications can use 8 TB of user mode address space.
As you know 16's and 32 will work fine as long as they are loaded under the 2GB level and a pointer is set to the same. Please think about the 16 and 32 bit thunker and look at it's doc's at m$. Notice that the thunker can only address x amount of memory as no one ever thought we would have more than a few megs. But, just because your system does not have more than 2 gigs mem-ram does not let you off the hook 8^}.
Please remember data is data, is data. just as you may load a text file into memory, you may load another resource into memory, right? You could open a dll in bin mode and read it yes?
Now come the problem of an insertion point, well the best I can explain this is search for it in your favorite bin editor. Next grab the offset and you golden.
Your must load absolutly, and create a pointer to the dll's and the offset, just as you would a thread to another exe or resource....that get's you the dll set to open, next in the dll header make a friend to the dll. Ole'(I name the dll something else, but that is another issue, see the idea thought?)
I have loaded 16's using this method and dllhelp. Now comes the problem of addressing the values in memory.Do not use the thunker. use your new pointer.
Write the data to the disk, and next go to M$ Please read and download the thunker compiler from M$ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win9x/tc_1582.asp
OK, a thunker compiler take a simple script that uses the reserved words below.
Now create a thunker that loads the newly formed file with the help of dllhelper.
Doh!, DO NOT DOWNLOAD A Thunker from the net as many are trojan's, go to M$
Keyword Meaning
enablemapdirect1632=true; Specifies a 16-bit to 32-bit thunk.
enablemapdirect3216=true; Specifies a 32-bit to 16-bit thunk.
input The parameter is used for input only; it is translated when the function is called.
output The parameter is used for output only; it is translated when the function returns.
inout The parameter is used for input and output; it is translated when the function is called and when it returns.
faulterrorcode Specifies the error code when a 16-bit to 32-bit thunk fails because the 32-bit DLL cannot load or initialize. This value is returned when the application calls the first thunk. For more information, see Late Loading.
preload32 Forces the 32-bit thunk DLL to load when the 16-bit thunk DLL is loaded in a 16-bit to 32-bit thunk.
preload16 Not used. Late loading of a 16-bit DLL in a 32-bit to 16-bit thunk is not supported.
win31compat Defers unloading a 32-bit thunk DLL until the process terminates. For more information, see Compatibility with Existing 16-bit DLLs.
You must ship the new thunk with your product.
M$ says: "Compatibility with Existing 16-Bit DLLs
There are certain steps you must take to ensure compatibility with existing 16-bit DLLs. Using the win31compat statement in the thunk script causes the unloading of a 32-bit DLL to be deferred until the containing process terminates. Use this statement to ensure that interprocess loading and freeing procedures, which may have worked with the 16-bit DLL when it was called from 16-bit code, will not cause the 32-bit thunk DLL to be freed prematurely. It also allows the 16-bit library to be freed without execution of the 32-bit DLL's notification routine an occurrence that could cause reentry into 16-bit code.
You must use the win31compat statement if a 16-bit DLL replaces a DLL that is currently used in a Windows version 3.1 environment or if the DLL runs as part of a graphics device interface (GDI) device driver. You might need use this statement even if your 16-bit DLL does not fit into one of these categories, because it provides extra protection from other DLLs that might be used by your thunk DLL."
The college where I teach part time has a very old accounting package that will only run on 3.1. I used this method to load the dll's and create new dll's from the old. Thanks M$ for another unlubed screw..g! Thunking is easy, entry points are tuff!
I will try to hack out an example over the winter and post an article.
This is bound to be a longhorn issue as M$ intends to stuff the box so full of mem-ram that it will be un-nesessary to write efficient code. (i.e. longhorn Noun: a stupid breed of cattle that are ofthen killed by lightning while standing under trees in thunder showers)).
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
1. We have our own perfomance monitor object which works OK Windows 2000 32-bit, but does not work OK 32-bit Windows 2003 for Counter Logs, but System monitor is working OK on all platforms.
******Log**************
(PDH-CSV 4.0) (India Standard Time)(-330) \\CANON\XXXX(000000 G \Avg. Disk Bytes/Transfer
11/19/2004 11:18:26.312
11/19/2004 11:18:27.296
11/19/2004 11:18:28.296
11/19/2004 11:18:29.296
11/19/2004 11:18:30.296
11/19/2004 11:18:31.296
11/19/2004 11:18:32.312
11/19/2004 11:18:33.296
11/19/2004 11:18:34.296
2. Also, If we are selecting all instances and all counters under Counter log, all instances are not comming
on Windows 2003 but working on Windows 2000.
This is just the main code extract on how are are doing, we have done no changes to the code for
different plaforms.
********************** Code Extract*******
IEnumWbemClassObject l_penumerator;
IWbemServices* l_services;
ULONG l_uljunk;
DWORD NUM_INSTANCES = 0;
IWbemClassObject** l_ppcop = NULL;
..
..
l_Hr = l_services->CreateInstanceEnum(bs,WBEM_FLAG_SHALLOW |
WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &l_penumerator);
..
..
..
l_Hr = l_penumerator->Next(INFINITE, 1, &l_ppcop[NUM_INSTANCES], &l_uljunk);
/* PROBLEM: In Win2003, it is breaking on the very first time.
but in Win 2K, it is enumerating properly */
if(l_Hr == WBEM_S_FALSE){
break;
}
********************** Code Extract*******
If we are not use WMI objects, it seems to be OK, please suggest what could be wrong with WMI.
Also, if there are sample code working using WMI on Windows 2003, please send it to me. Any help on this would be great
Thanks and Regards
Deepak
|
|
|
|
|
Need this urgently, someone has any idea on it
|
|
|
|
|
anyone know anything about authentificated smtp, I need to make a program that can connect to such a smtp server and it needs to support smtp authentification
I read the RFC but I didn't understand a thing
SO can anyone help me, tell me how I can log in to one of these serverswith username and password I assume that the rest is similar to sending mail via smtp withouth authentification.
thank you in advance
|
|
|
|
|
|