|
First of all your thread proc cannot be a non-static member function of a class. Either make it static or use a global function as thread proc.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
HI Guys
I wanna run my application as Win NT service.
How do i wanna do?
I want to create an exe, with input parameters as
1. User Name
2. Password
3. exe\batch File Name
I want to run "exe\batch File Name" as Win NT service with user name and password.
How can i do it?
Help needed ASAP.
Regs
Rohit
|
|
|
|
|
http://www.codeproject.com/system/serviceskeleton.asp
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Hi all,
I used Crystal Report 8.0 in my VC++ 6.0 without any problem, but in VC++ .NET Crystal Report control have other function for allthing !
Below source code worked in my VC++ 6.0 project and now i have problem in VC++ .NET project:
strFormula = "{TABLE1.ID} = 1";
m_Report.put_SelectionFormula(strFormula);
as you can see, there is a simple for Selection formula !
ATTENTION: in VC++ 6.0, you must use SetSelectionFormula function
It is my second question, why I must use of different of functions in VC++ 6.0 and VC++ 7.0 ?
Help me !!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi.
Regarding C++ windows programming, is it a convention to include both data type and variables names for function parameters in the declaration file?
For example:
class MyFrame : public CFrameWnd{public: MyFrame(); functionA(int &var, char &str); protected: afx_msg OnPaint(); afx_msg OnLButtonDown(UINT nChar, UINT nRep, UINT nFlags);// afx_msg OnLButtonDown(UINT, UINT, UINT);...private:...};
I am used to not including anything more than what is necessary.
Kuphryn
|
|
|
|
|
kuphryn wrote:
Regarding C++ windows programming, is it a convention to include both data type and variables names for function parameters in the declaration file?
yes. but it has nothing to do with Windows. it just makes it easy (or even possible) for other programmers to use your classes.
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
The advantage is that intellisense will also show the variable name you used. Thus by using meaningful variable names you could really improve things for others using the class.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Hey all,
I am trying to use import to automate Outlook to send email for my CGI program.
However, outlook stays in memory after my program is finished and my program
got stuck with outlook too, can anybody tell me why and how to solve it?
Thanks a lot and the following is my code for sending email:
void Sendfile(){
try
{
_NameSpacePtr pNameSpace;
MAPIFolderPtr pOutbox;
_ItemsPtr pOutboxItems;
_MailItemPtr pNewMail;
AttachmentsPtr pAttachments;
RecipientsPtr pRecipients;
char eachfile[100];
char eachemail[100];
char eachcustmail[100];
int pos;
//fileLocation, set to 150 character lenght
char filelocat[250];
// Create an Outlook.Application pointer.
_ApplicationPtr pApp("Outlook.Application");
// Create NameSpace pointer.
pNameSpace = pApp->GetNamespace(L"MAPI");
// Logon in OutLook
pNameSpace->Logon(LogonTo);
// Create pointer to the Outbox Folder.
pOutbox = pNameSpace->GetDefaultFolder(olFolderOutbox);
// Create pointer to the Messages Collection.
pOutboxItems = pOutbox->Items;
// Create pointer to a new message.
pNewMail = pOutboxItems->Add();
// Set the Subject of the message.
pNewMail->Subject=subject;
// Set the Text of the message.
pNewMail->Body=body;
// Set the BCC address (already define in the header file)
pNewMail->BCC=BCC;
// Create pointer to the Attachments collection.
pAttachments = pNewMail->Attachments;
//Loop for Attachment for each file
pos=0;
while (pos <= (int)(strlen(filename)) ){
getStringNext(filename,pos,eachfile);
strcpy(filelocat,path);
strcat(filelocat,eachfile);
// printf("%s\n",filelocat);
if (IsExist_Notnull(filelocat)){
// Create new Attachment. path
pAttachments->Add(filelocat, (long)1, (long)(15000),
eachfile);
}
}//end while
// Create pointer to Recipients Collection.
pRecipients = pNewMail->Recipients;
//Loop for input string to extract mail addresses
pos=0;
while (pos <= (int)(strlen(custmail)) ){
getStringNext(custmail,pos,eachemail);
strcpy(eachcustmail,eachemail);
// printf("%s\n",filelocat);
// Add recipient.
pRecipients->Add(eachcustmail);
}//end while
// Resolve the recipient address.
pRecipients ->ResolveAll();
// Send the message.
pNewMail->Send();
// Logoff NameSpace.
pNameSpace->Logoff();
pApp->Quit();
return;
}
catch (_com_error &e)
{
dump_com_error(e);
return;
}
}//end
|
|
|
|
|
You probably need to release the object. try adding pApp->Release();
after pApp->Quit();
Good luck,
Bill
|
|
|
|
|
I have a ULONG called uProdTypeTemp that has a value of '128' I need to reverse that value and place that back into a different ULONG so that it reads '821'. See code below:
These next two lines must NOT change:
const unsigned long ACTCODE_BYTE_LENGTH = 20L;
BYTE ByteList[ACTCODE_BYTE_LENGTH];
ULONG uProdTypeTemp = ByteList[10];
Thanks,
Derek Smigelski
|
|
|
|
|
turn it into a std::string with an ostringstream, I'm sure STL will have an algorithm to reverse it, then use atoi to get the reversed number out.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
char tmpstr[5];
sprintf(tmp,"%d",uProdTypeTemp)
char tmp2=tmpstr[0];
tmpstr[0]=tmpstr[2];
tmpstr[2]=tmp2;
uProdTypeTemp = atoi (tmpstr);
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
Greetings all,
what i'm looking to do is use this multiport nic card. 2 port with ip's being..
192.168.0.1 and 0.2
connecting the ports is a crossover cable.
what i'm looking to do is somehow bind to one ip(or port) to send....and likewise on the other to receive....AND having all transmissions go thru the crossover cable.
i wrote a very small app doing just such using CSockets. however when the app is run the data is transferred but not thru the crossover cable. This tells me the OS(nt4) knows the ip's are internal and not to send them out.
anyone know how i can have the data transmitted OUT across the line and received in on the other port?
any help is greatly appreciated,
Eric
|
|
|
|
|
Can you set up arp entries mapping these to the respective MAC addrs of the NICS?
|
|
|
|
|
i added arp entries for each ip and still nothing. the program will still transmit the data just fine...just not across the crossover cable. For some reason it's transmitting the data internally and not through the cable.
Eric
|
|
|
|
|
I think I misread your initial post - I thought there were two cards - is the MAC address then the same for each arp entry?
Hmmm... seems to be treating them as localhost entries - any oddities in the system32\hosts file?
oops - I mean systen32\drivers\etc\hosts
|
|
|
|
|
The MAC address is different for each entry
|
|
|
|
|
I am investigating an issue with some software at work and am looking for some suggestions. The software takes messages from a source outside of the application and will display them, one by one, to a list control. The list control is set to have a max size and will delete an entry before inserting one when it has reached its max.
The problem is that occassionally, the messages are available at such a fast rate, that they are missed by the application. I have done some experimenting and have found that when a portion of the list control is covered by another window, the messages are no longer being missed. This leads me to believe this is an issue with involving time spent refreshing the control. Any input is appreciated. Thanks.
-Andrew
|
|
|
|
|
Storing the messages internally and displaying them on demand via a virtual list control sounds like it might work for you. I thought there was an article on the subject here on CP; unfortunately i can't find it now. A Google search should find what you need though.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
Hi,
I'm a new babie in Thread programming, and now i'm trying to taste what is thread programming. Now I got a sample program that using <process.h> library. It uses _beginthread(transaction1, 0, (void *) obj) to create a thread. My questions are:
1. What are those parameters mean?
2. I know....end_thread() is to end the thread....but can I suspend awhile and then resume a thread??? What are their function names?
3. If I want to create 1000 transaction at once (doing the same thing), can I use a for loop to loop 1000 times and create this thread?? If YES, how can i choose which thread to end/suspend/resume???
e.g. for i = 1 to 1000
_beginthread(transaction, ..... )
I got lots of articles about thread in MFC. But i just want to understand this sample program first. Can anyone help me????
THANK YOU!!!!!!!!!!!!!!!!
|
|
|
|
|
Hi,
1) The first parameter is the function which will represent the execution of your thread.. in other words, this function is going to be call after _beginthread(...)
Second one is the Stack Size, 0 most of the time.
<documentationcopypaste>
The operating system handles the allocation of the stack when either _beginthread or _beginthreadex is called; you do not need to pass the address of the thread stack to either of these functions. In addition, the stack_size argument can be 0, in which case the operating system uses the same value as the stack specified for the main thread.
Third: This can be a pointer to any type (struct, object, primitive type, etc..) you need. For example, if you need to pass several variables to the thread, probably the best way is to create a struct (or object) containing this variables and pass a pointer to this struct.
2) Search for Mutex or Semaphore, I think this is what you are looking for.. or maybe Sleep(...) if you want to suspend a thread for a given time.
3) You could, which does not mean is a good idea .
you probably don't want to create 1000 threads cause it produce resources overhead.
hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
ChiYung wrote:
I know....end_thread() is to end the thread....
Don't do that... it is bad.
I vote pro drink
|
|
|
|
|
Hi.
ChiYung wrote:
_beginthread(transaction1, 0, (void *) obj)
Make sure that obj is a pointer to a dynamically allocated object, or in some other way a pointer to data that won't magically disappear like a stack variable will.
ChiYung wrote:
2. I know....end_thread() is to end the thread....but can I suspend awhile and then resume a thread??? What are their function names?
SuspendThread() and ResumeThread() handle this. The standard, safe way for your thread to exit is when you exit your thread proc. Calling end_thread() or TerminateThread() is , as mentioned below, a Bad Thing.
ChiYung wrote:
If YES, how can i choose which thread to end/suspend/resume???
Take a look at using AfxBeginThread() instead. It returns a CWinThread* and that class contains a handle to the thread. That comes in handy when you want to make sure, for instance, that your thread has terminated before you do something else - you can call WaitForSingleObject(pThread->m_hThread, cbAlertable) to wait until the thread finishes - the handle will be signalled when it is.
Additionally, if you want to start a thread suspended, do some processing, and then resume the thread you can pass the suspended flag in to AfxBeginThread(), and then call ResumeThread() when you're ready to wake it up again.
One other thing that you reeeeeeeaally want to watch out for is data synchronization between threads. Check into the CMutex, CSemaphore & CCriticalSection classes to lock a data variable while you're using it and then unlock it when done. This prevents other threads from altering it underneath you, another Bad Thing.
The other bane of multithreaded programming is the dreaded race condition, where two threads are spinning along, and it's just sheer chance who does which operation first. That's a real pain in the tookus to debug. Using the synchronization objects and also using events (CreateEvent()) and waiting on them via WaitForSingleObject() can help there.
Of course, once you start working with blocking on events, etc. you run the risk of a deadlock, where 2 locks happen, but each is waiting for the other to let go, resulting in two threads that stand still until dinner at the Restaraunt at the End of the Universe (Milliway's, of course).
Ain't multithreaded programming fun? Actually, the best advice I have about threading is Obe Wan's line from the first Star Wars movie -
"Run, Luke!"
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
Ain't multithreaded programming fun? Actually, the best advice I have about threading is Obe Wan's line from the first Star Wars movie -
"Run, Luke!"
LOL...
To me, multithreaded applications are a lot like pointers. The first time you see them, you run for your life. But after you get a few applications under your belt, they really aren't that bad.
After doing it for nearly 15 years, I just naturally think multithreaded now.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
To me, multithreaded applications are a lot like pointers. The first time you see them, you run for your life.
There's a legend at my shop of one programmer who, during the DOS days, successfully executed the interrupt vector table with a bogus pointer. Some types of fame I think I can live without...
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|