|
you can get the ProcID of the process using a function like this:
DWORD RunningInterface(char* Fileexec)// executable name
{
PROCESSENTRY32 uProcess;
HANDLE phandle;
DWORD dwSessionID= 0xfffff;
phandle = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
uProcess.dwSize = sizeof(uProcess);
BOOL r = Process32First(phandle, &uProcess);
int index = 0 , numofinstance = 0;
while(r)
{
if(stricmp(uProcess.szExeFile , Fileexec) == 0)
{
ProcessIdToSessionId(uProcess.th32ProcessID,&dwSesssionID);
//CloseHandle(phandle);
break;
}
r = Process32Next(phandle, &uProcess);
};
CloseHandle(phandle);
return dwSesssionID;
}
Now we have got the sessionID we can easily get the user associated with this session ID using a function similar to this :
bool GetTSUserName( DWORD sessionID , char *mmusername )// mmusername will be returning you with the user // name associated with this session ID
{
LPTSTR ppBuffer = NULL;
DWORD pBytesReturned = 0;
strcpy(mmusername , "");
if( WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE,
sessionID,
WTSUserName,
&ppBuffer,
&pBytesReturned) )
{
//currentUserName = CString( ppBuffer );
strcpy(mmusername , ppBuffer);
if((stricmp(mmusername , "") == 0 ) || (strlen(mmusername) == 0 )){
strcpy(mmusername , "Unknown");
return false;
}
}else{
strcpy(mmusername , "Unknown");
return false;
}
WTSFreeMemory( ppBuffer );
return true;
}
Hope this helps
Kushagra
|
|
|
|
|
I'm looking into porting some apps to VS2010 for a client. Some of their tools manipulate the .rc file directly. Could anyone with VS2010 installed please send me a .rc file that was created with VS2010 (not converted, but actually newly created by VS2010). Thanks!
hdietrich at gmail dot com.
|
|
|
|
|
I have sent a 2010 (Beta 2) resource to your gmail acount. Please check your inbox.
|
|
|
|
|
Hi,
I have a exe file. I want to change the caption (title) of this application.
How can I do this?
|
|
|
|
|
A window caption is set using the SetWindowText function.
To change the caption of the main window you have to pass in the handle of the main window handle.
|
|
|
|
|
How to get handle of running window?
|
|
|
|
|
If you're using MFC, you can do AfxGetMainWnd()->SetWindowText(_T("New Caption")); to set the caption of the main window.
If you're using Win32, you can get the window handle from the first parameter of the window procedure.
|
|
|
|
|
I used FindWindow() to get the handle. But sometimes FindWindow() fails to get the handle.
FindWindow(NULL,"Mine");
Can you suggest me another way?
|
|
|
|
|
As Avi Berger mentioned, are you using an application to change the caption of yet another application?
If not, you do not need to use FindWindow ?
Also you haven't answered the questions in my earlier post.
|
|
|
|
|
Just to clarify - is this:
1) a program you are writing in C or C++,
or
2) a third party program that you only have the binary for that you want to change by hacking the exe file
or
3) a third party program that you only have the binary for whose run-time behavior you want adjust from another program running at the same time?
I believe that «_Superman_» is answering based on #1, which makes most sense considering where you are posting. You wording, however, sounds more like #2 or possibly 3 to me.
|
|
|
|
|
|
I am looking for a charting control to be used in an MFC application that we want to convert to 64 bit. We have used ComponentOne Chart for years, but they do not have a 64-bit activeX version, and it looks like they aren't going to develop one.
Requirements include:
* 64-bit activeX control
* line charts
* what excel would call scatter charts -- chart a line based on X and Y data where the X values are not evenly spaced.
* surface charts, where the input is Z values at X and Y coordinates, and the control charts a wire-mesh, or a smooth surface.
* contour charts, where again the input is Z values at X and Y coordinates, and the control charts contour lines, or contour color bands.
* can zoom in on the data, either through user interaction, or programatically.
* ability to handle large amounts of data. In the 3D surface charts, we would like to be able to handle at least 100x100 so 10,000 data points, and 500x500 (250,000 data points) would be nice.
I have searched and haven't found anything that meets our needs. Any suggestions?
TIA,
Don
|
|
|
|
|
Hi
I am using CFile to implement my IO. But in the middle of reading/writing, I need to read/write a bitmap to the file. Is there a way convert a CFile object to a "istream" object?
Thanks,
|
|
|
|
|
Why do you want to convert to istream ?
You can use the Read /Write methods of CFile to write the bitmap to the file.
The file must of course be open in binary mode.
|
|
|
|
|
Thank you for your reply.
I need to construct a DIB BITMAP which constructor uses a "*pIStream" as parameter.
I might be able to read data into a string buffer.
Thanks,
|
|
|
|
|
May be you can take a look at SHCreateStreamOnFile() API.
|
|
|
|
|
I'm curious to know if having a small number of .mdb databases connections open at the same time will tax systems or if it's ok to do assuming they are only open for a brief instant in time.
Details:
For applications that briefly open an .mdb file while initializing, I normally try to pass a reference to an instance of CDatabase that has been opened on a database while loading data from tables. I'll usually close the database connection once I know I'm done. The database remains open for less than a second.
I'm now faced with the need to read from multiple .mdb files while initializing, with no guaranteed order, and the potential to need to alternate reads between the databases. I've noticed that there is a big time difference if I close the old database connection and open a new one when I need to switch which database I'm reading from.
My intention is to keep a small array of those open database connections to keep the duration of the loading time to a minimum and close them promptly once I'm done.
Are there any hidden "gotchas" to doing this? Is it unwise to keep more than one instance of a database open at a time?
|
|
|
|
|
Well, after benchmarking many combinations using multiple .mdb files, this does not affect performance or memory usage in any significant way.
(For anyone who might stumble upon my question and wonder how this ended up)
|
|
|
|
|
Hi all,
I got a txt file filled with HTML code extract from www.finance.yahoo.com
this is the data from finance.yahoo.com
Dow 10,212.73 +27.20 +0.27%
Nasdaq 2,174.00 +2.80 +0.13%
10 Yr Bond(%) 3.6500% -0.0400
Oil 75.25 +0.82 +1.10%
Gold 1,113.60 +10.10 +0.91
the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com.
so, how should i create the method and what parameter should i pass in?
should i create individual method for each stock? example
double getDOW(param1, param2, param3, etc)
or a generic method that can search any stock quote
|
|
|
|
|
Use getline or CStdioFile to read the file line by line.
Then use strtok_s or CString::Tokenize to extract the values from each line.
|
|
|
|
|
You can have one method to read the "raw" data for each data line as long as they follow the same pattern, for example, in your case, it looks like:
<name> <data1> <data2> <data3>
after that, you have to interpret each data like depending on where it comes from, is it from Dow ? is it from "Oil"? and decide if it's a percentage, a absolute value, a "delta" and put those values in the appropriate fields in your application :
if ( <name> == Dow )
{
...
}
else (if <name> == Nasdaq )
{
...
}
...
Technically, there must be dozen different ways to do that, but I try to keep it as simple as possible.
Good luck with that.
This signature was proudly tested on animals.
|
|
|
|
|
benjamin yap wrote: all the values need to be read from the HTML text file of finance.yahoo.com.
Use the IHTMLDocument interface to navigate the HTML.
Did you read this article suggested to you three days ago?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
how do i extract 2,190.06 from here?
<span class="streaming-datum" id="yfs_l10_^ixic">2,190.06</span>
The ihtmldocument quite complicated to understand
|
|
|
|
|
benjamin yap wrote: how do i extract 2,190.06 from here?
Look for a SPAN element named yfs_l10_^ixic. Then use one of the innerText , outerText , innerHTML , or outerHTML properties.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
do i have to
#include anything to use the innertext, outertext etc etc?
|
|
|
|