|
Many thx.
Looks like it solved the problem with the privileges only problem now is the call to CreateProcessAsUser fails with GetLastError returning "The Operation completed successfully"
and no, the process was not started.
if(CreateProcessAsUser(HToken
, NULL
, "myapp.exe" // present in system32
, NULL
, NULL
, TRUE
, NORMAL_PRIORITY_CLASS
, NULL
, m_pSchedule->DirectoryBuff
, &st
, &proc) == 0)
{
... GetLastError, CloseHandle(HToken), return
}
CloseHandle(HToken);
btw Im launching a dos program (I dont wish to c the window) - before, when using CreateProcess, I was using the flag CREATE_NOWINDOW which was successful.
|
|
|
|
|
I do not know about creating a process as a user, but I did the following..
CString _sTitle("Title of the window");
STARTUPINFO stInfo;
PROCESS_INFORMATION psInfo;
ZeroMemory(&stInfo, sizeof(STARTUPINFO));
ZeroMemory(&psInfo, sizeof(PROCESS_INFORMATION));
stInfo.cb = sizeof(stInfo);
stInfo.cbReserved2 = NULL;
stInfo.lpDesktop = NULL;
stInfo.dwFlags = STARTF_USESHOWWINDOW;
stInfo.wShowWindow = SW_SHOW;
stInfo.lpTitle = _sTitle.GetBuffer(_sTitle.GetLength());
_sTitle.ReleaseBuffer();
CreateProcess("watchdog.exe",
"cmdline params" ,
NULL,
NULL,
TRUE,
CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE ,
NULL,
NULL,
&stInfo,
&psInfo);
// Wait a bit for the process to init
// But maximal 5 seconds
WaitForInputIdle(psInfo.hProcess, 5000);
It might be that the process is initializing ?
|
|
|
|
|
Thx Phil for the reply - yeah CreateProcess works fine was using that before but CreateProcessAsUser is the painful culprit unfortunately I'm still left with an uninitialised PROCESS_INFORMATION object when the call fails - and GetLastError says it completed successfully
|
|
|
|
|
This is probably a total beginner question!!
How do I convert ..
int iID =5
into a
CString strID
Thanks
|
|
|
|
|
strID.Format("%d", iID) should do the trick...
-Mike Zinni
Software Engineer
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|
|
Thanks for answering me. I thought that would solve a problem that I'm having but it doesn't. So maybe you can help me with this.
The following lines of code are supposed to retrive data from a database. I know this works when all values in the database are strings. But now the first column are integers. The error I get is below. Do you know how I can fix this?
Thanks,
Alan
/***************************************/
long iID;
CString strName, strNumber;
...
while (!recset.IsEOF())
{
//Copy each column into a variable
recset.GetFieldValue("Address ID",iID);
recset.GetFieldValue("First Name",strName);
recset.GetFieldValue("Home Number",strNumber);
//Insert values into the list control
iRec = m_MyListControl.InsertItem(0,iID,1);
m_MyListControl.SetItemText(0,1,strName);
m_MyListControl.SetItemText(0,2,strNumber);
//Go to the next record
recset.MoveNext();
}
Error:
void __thiscall CRecordset::GetFieldValue(const char *,class CDBVariant &,short)' : cannot convert parameter 2 from 'long' to 'class CDBVariant &'
|
|
|
|
|
I havent done much with CRecordSet. But if you have no problems with CStrings, then get the first column into a CString and then convert it to an integer.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
You should use a CDBVariant object like this: (read MSDN for details about CDBVariant)
CDBVariant dbv;
recset.GetFieldValue ("Address", dbv);
iID = dbv.m_lLong;
or you can read it in a CString and then call atoi function to get an integer value
If you are going to port your application to VC7 you will notice that GetFieldValue does no longer take a CString as a first parameter. So you should use:
recset.GetFieldValue ((short)0, strName);
This is one bit of VC 6.0 that does not compile on VC 7.0
Best regards,
Alexandru Savescu
|
|
|
|
|
You have two choices here. You can either construct and pass a CDBVariant or you can pass a CString and convert the returned value:
CString strID;
recset.GetFieldValue("Address ID",strID);
long iID = atol(strID);
CDBVariant v;
v.Clear();
v.m_dwType = DBVT_LONG;
recset.GetFieldValue("Address ID", v);
I'm typing this without testing it, but this should be very close to what you need.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
i think the best way is
take an object CString strID;
use the following for conversion
strID.Format(" %d ",iID);
strID is a string object containing 5 as string value
u can convert anything into string
eg:
pointer ptr can b converted as
strID.Format(" %x ",ptr);
|
|
|
|
|
I'm building a Document/View based program.
When a user wants to use the program the following should happen:
a) A login dialog box should appear on the screen
b) If a user enters a valid login the program should become accessible
c) If a user enters invalid login information the program should end
d) And also if the user presses Cancel the program should end
something like this:
CDlgLogin dlg;
int nLogin = dlg.DoModal ( );
if( nLogin == IDOK )
{
//check login information
}
else if( nLogin == IDCANCEL )
{
//shutdown the program
}
What I'm not sure about is WHERE to put this information
I've tried the "ProgramView.cpp" and "MainFrm.cpp" files but I always get silly access violations or something like that when a user presses "Cancel"
What do I need to do for this to work ? Please please help me if you can
Best wishes from Iceland
Solini
|
|
|
|
|
The easiest way is to put that stuff into the CYourApp::InitInstance
Regards
Thomas
Finally with Sonork id: 100.10453 Thömmi
Disclaimer: Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.
|
|
|
|
|
A good place to insert this is in your CWinApp -based InitInstance , just before anything else. If the login fails, just return FALSE .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
we have a login screen just as you describe
at the end of InitInstance() we post a message to ourselves mimicking the 'log on' toolbar button
the logon box pops up very nicely
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
Thank you everyone... putting the doModal( ) into the InitInstance function worked perfectly
|
|
|
|
|
I need to change the background color of an OCX composite control at a regular basis. When I do this the composite control and all controls within are redraw. This causes the application to flicker. Can this somehow be prevented?
|
|
|
|
|
Can you modify the source code of the OCX? If so, consider using double-buffering when painting. Check Keith Rule's Flicker Free Drawing In MFC.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx for yor reply. I can modify the OCX code, however my OCX is a composite control and it seems that the OnDraw is never called, instead the CAXWindowHost::OnPaint. Overloading this call seems tricky, do you know how I can trigger the OnDraw of the composite control?
|
|
|
|
|
Hi,
I have written a small application using DirectShow that plays an MPEG or AVI movie in full screen mode. My code is based on the "playit" sample code that comes with the DirectX SDK (or at least it came with 6.1), and it uses WinAPI. All I want to do is have it so that the movie finishes (exits) as soon as you press any key on the keyboard (or one of the mouse keys, though that's not as vital). This is probably a very dumb question (I am very new to DirectX and not a very experienced programmer in general), but how can I do this? I *think* that I somehow need to send the message EC_USERABORT to the movie window as soon as the user presses a key. I have tried using put_MessageDrain() and so on, but it doesn't seem to recognise my window - or at least, it doesn't work.
This is the main loop of the PlayMovie() function:
long evCode, param1, param2;
bool bcomplete=false;
while (hr = pME->GetEvent(&evCode, ¶m1, ¶m2, INFINITE), SUCCEEDED(hr))
{
switch(evCode)
{
case EC_USERABORT:
bcomplete=true;
break;
case EC_COMPLETE:
bcomplete=true;
break;
}
hr = pME->FreeEventParams(evCode, param1, param2);
if(bcomplete==true){break;}
}
If anybody could tell me how to get my movie to close as soon as the user hits any key, I would be very grateful.
Many thanks for any help,
KB
P.S. Apologies - I posted a similar message a few days ago; however, I am still stuck and my old post seems to have been lost pages back...
|
|
|
|
|
Hi, is it possible to get the information of the display card through C++? Any sample code? Thanks.
|
|
|
|
|
EnumDisplayDevices to get the video cards
EnumDisplayMonitors for the monitors
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
How do I set the mouse position (in absolute coordinates) in Win32?
Thanks.
Isaac Sasson,
Lean, mean posting machine!
Sonork ID 100.13704
|
|
|
|
|
Use this function:
BOOL SetCursorPos(
int X,
int Y
);
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks! I forgot the function name and I'd hate to look through MSDN.
Isaac Sasson,
Lean, mean posting machine!
Sonork ID 100.13704
|
|
|
|
|
I think that looking through MSDN is a skill that you become good at only after years of practice and experience.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|