|
Define a class member variable that hold a pointer to dialog, then access CEdit through that member.
|
|
|
|
|
how to assign exeName1 to processname[0]
CHAR exeName1[15];
static char ** ProcessName;
ProcessName = new char*[2];
GetPrivateProfileString ("AC", "exe1","", exeName1, 50,"C:\\exe1.ini");
ProcessName[0] = exeName1; //// giving error
can u please help me
Thanks
abhi
|
|
|
|
|
ProcessName is a pointer to a pointer.
Right now, it points to an array of two char *s. You probably want to do this:
static char ** ProcessName;
ProcessName = new char*[2];
ProcessName[0] = new char[15];
ProcessName[1] = NULL; //Until it gets a real value.
::memset(ProcessName[0], 15, 0); // Possibly change the 0 and 15, can't recall.
GetPrivateProfileString ("AC", "exe1","", ProcessName[0], 50,"C:\\exe1.ini");
What does the second char * in the array point to ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
abhiramsss wrote: ProcessName[0] = exeName1; //// giving error
There are 2 problems here. First, your array is an array of 2 character pointers, so when you set exeName1 to ProcessName[0], you are just setting the pointer value to point to that. The problem is that, since exeName is on the stack, it's type is char[] and not char* (slight, but important difference). Also, since it is on the stack, when it goes out of scope, that pointer is no longer valid anyway (so you would have a dangling pointer). What I believe you want to do is:
static char** ProcessName = new char*[2];
memset(ProcessName, 0, sizeof(char*) * 2);
ProcessName[0] = new char[15];
memset(ProcessName[0], 0, sizeof(char) * 15);
GetPrivateProfileString("AC", "exel", "", ProcessName[0], 14, "C:\\exe1.ini");
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
is it possible to check a checkbox in the remote application?
if it is, please some hints, how?
etc.: if windows calculator has Hyp and Inv checkboxes and i need to check one, how to do that?
thank you in advance for any help while(1==1) write( );
|
|
|
|
|
I'm not sure how you would grab the handle of an object in another application window ... It may be possible, But if that does no work...
Mabey you can find out the window cords of the other window. Then move the mouse to the location of the box and simulate a click.. I've seen some applications do stuff like that, And I can only figure it was the only thing they could come up with to get the job done... But I'm still a seasoned noob.. So I don't really know... Just a thought..
Let me know what you come up with.. Controlling other apps would be a nice thing to know. Good luck..
|
|
|
|
|
hmm good idea to use mouse click simulation... well at a last resort i could use that
but lets say i know such information of the window/object(by using WInSpy):
Window::::::::::::::
Handle: 0x00010942
Control ID: 141
Text: Hyp
Class: Button
Style: 0x50010003
Rect: (165, 232)-(216, 248) 51x16
Thread ID: 0x0000085C
Process ID: 0x00000580
Parent Window:::::::::
Handle:0x0001093E
Text:Calculator
Class:SciCalc
is it useful?
|
|
|
|
|
Ok.. I need to do a formula like this, but my message box alwayse shows 0 no matter what the variables are...
int var1 = 25;
int var2 = 50;
temp.Format((L"%d"), ( (var1 / var2) * 100) );
AfxMessageBox(temp);
|
|
|
|
|
Because with integers, var1 / var2 = 0.
Try this
int var1 = 25;
int var2 = 50;
temp.Format((L"%d"), ( (var1 * 100) / var2) );
AfxMessageBox(temp);
|
|
|
|
|
|
I am writing some software that needs to interact with an FTP server. I am using the CFTPFileFind class to run through the files and find/get what I need. Some ftp sites I have no problem, but on others I get a timeout when I call CFTPFileFind functions.
I am sure that there is no other issue, as the ftp site is a command line param for this app; some ftp sites work and others do not.
Is there a setting that must be set on the ftp server to allow this kind of interaction? Anyone have an idea of why this might be happening?
|
|
|
|
|
When your FTP application is acting up, do other FTP applications work for those same sites?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Do you mean can I connect and download/upload, view files, etc. with a normal ftp client? Yes, I can connect to the sites, move files around, and everything works fine. I've used the dos ftp client and CuteFTP.
For the sites it doesn't work on, when I call CFTPFileFind::FindFile(NULL), it hangs for a few minutes and then returns a timeout. If I try ftp.microsoft.com, everything works exactly as expected. But if I connect to my company's ftp site, I can connect and navigate directories no problem, but FindFile won't list any files. And I wiped out everything on the ftp site, and just put 3 little text files there for testing, so I know it's not too many files to list before a timeout.
|
|
|
|
|
This is my function :
CThreadPool::t_Job& CThreadPool::CJobQueue::getJob()
{
WaitForSingleObject(m_JobListMutex, INFINITE);
for ( std::deque<t_Job>::iterator it = m_JobList.begin(); it != m_JobList.end(); it++ )
if ( it->m_JobState != JOB_WORKING)
{
it->m_JobState = JOB_WORKING;
ReleaseMutex(m_JobListMutex);
return (*it);
}
ReleaseMutex(m_JobListMutex);
}
I don't want to use a pointer for return. And i don't think it's apropriate to throw an exception, since that scenario is unavoidable, in fact quite regular. My only Idea left would be to return some special reference to a static element that functions as sort of a NULL. Any other ideas/comments ?
|
|
|
|
|
why not use an enum type of predefined statuses?
|
|
|
|
|
Mr.Brainley wrote: I don't want to use a pointer for return.
Why not?
I also question why INFINITE is hard coded? Does not seem appropriate for thread pooling.
Also does your pool provide a timeout mechanism to account for user code hogging and hanging threads?
Mr.Brainley wrote: Any other ideas
A smart pointer implementation that would encapsulate returning the thread to the pool etc.
led mike
|
|
|
|
|
I think my thread pool works different from what you think. Basically, i have a central semaphore that is increased by one each time a Job is added. On that, a thread wakes up and asks the queue for a job. The t_Job type of my example is a simple class containing a pointer to an interface with a function to execute, and state-information. The INFINITE wait here is just for the mutex on the jobqueue, wich of course needs to be synchronized.
The pool does not have a timeout mechanism. I don't think it is neccessary, since i write it for a very special purpose, but anyhow i would'nt know how to implement that. Can you give me a hint there ?
The main idea was, that whenever is thread is wakened by the semaphore, that means that there actually IS a job. But in Win32 you have to give a maximum count for a semaphore. Since i don't want to limit the number of jobs in my queue, i tried to find another solution, wich brought me to the problem at hand. I think i will just live with the limit (can set it high). The maximum workloud can be estimated and that will have to suffice.
|
|
|
|
|
Have you ever used an IO completion port?
It can be used for what you are doing without the semaphore release count limit.
Instead of IO you would use PostQueuedCompletionStatus() to post jobs and your pool of threads
wait for jobs using GetQueuedCompletionStatus(). When a waiting thread gets a completion
packet it already has the job (pointer) so it doen't need to retrieve it from a list.
It works pretty efficiently.
Just a thought.
Mark
|
|
|
|
|
I was not aware of such a thing. Thanks alot !
|
|
|
|
|
Mr.Brainley wrote: I was not aware of such a thing. Thanks alot !
No problem. I just happen to be working on some code using one right now
There's only 3 APIs and 1 structure involved so it's pretty simple and powerful.
You'll see most articles describe using them for scalable multithreaded IO but they also
make a handy queue for thread pools.
Cheers,
Mark
|
|
|
|
|
actually, I'm implementing this thread pool for a scalable multithreaded IO application. Well, seems i don't need to do that anymore.
|
|
|
|
|
Then you'll really like IO completion ports then. You can use the same pool of threads for
handling queued jobs and queued IO requests if you choose to. Works slick!
|
|
|
|
|
Return pointer instead of reference? That way you can safely use NULL to indicate "no job". Using exceptions for that is in my opinion a complete waste of resources...
May I ask why you are using mutexes? You could speed things up by using spinlocks (CRITICAL_SECTION). See docs for EnterCriticalSection(), LeaveCriticalSection(), etc, in the MSDN library. I'm assuming that the mutexes are never, or very seldom, held for a longer period of time. If they are, then mutexes is preferable, because they will put waiting thread to sleep rather than leaving it to "spin".
--
Now with chucklelin
|
|
|
|
|
Thanks for the advice on the Mutex. You are right, they are never held for long. I will change that.
|
|
|
|
|
I see now that you are opposing the use of pointers.. why? Pointers are an intrinsic concept in C++ - why work against it?
--
Presented in doublevision (where drunk)
|
|
|
|