?
Solved

points for jkr

Posted on 2002-05-30
19
Medium Priority
?
263 Views
Last Modified: 2010-04-02
>>can we have messageboxes in a service???,

Yes - all you need is to set MB_SERVICE_NOTIFICATION. Alternatively, use 'OutputDebugString()' and a
viewer like e.g. http://www.sysinternals.com/ntw2k/freeware/debugview.shtml ("DebugView").

your above comment helped me a lot and made my life easy,
the debug view is nice and thankx for the api "OutputDebugString" i ,i am really using it a lot.

so i am alloting 200 points for this question and 'A' grade for sure.

now i am struck with a problem,
myservice is calling a thread,
inside my thread i am trying to connect to ftp site ,when its unable to connect ,and if exception is raised, i am handling the exception also but whats happening is as soon as exception is raised the service is struked and its not ending at all.
plz help

0
Comment
Question by:srithi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
19 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 7044844
How are you handling the exception?
0
 
LVL 1

Author Comment

by:srithi
ID: 7046025
here is the code ,which causes exception ,
     
CFtpConnection *ftp;
          try{
          ftp = session.GetFtpConnection(rules.sFTPInIP,rules.sFTPInUser,rules.sFTPInPassword);
          }
          catch(CInternetException *p)
          {
                         OutputDebugString("Not Connected .....);
                              return;
          }    
0
 
LVL 86

Expert Comment

by:jkr
ID: 7046834
Have you tried

CFtpConnection *ftp;
         try{
         ftp = session.GetFtpConnection(rules.sFTPInIP,rules.sFTPInUser,rules.sFTPInPassword);
         }
         catch(CInternetException *p)
         {
                        char acBuf [ 1024];
                        OutputDebugString("Not Connected .....);
                        sprintf ( acBuf, "Reason %d\n", p->m_dwError);
                        OutputDebugString(acBuf);
                        delete p; // this is important!
                             return;
         }      
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:srithi
ID: 7047379
i don't want the reason, still should i have to do that,what i want is ,if my system(on which service is running) is not connected to internet ,i want to return from the function.

thankx.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7047497
You should at least delete the exception, as I pointed out above...
0
 
LVL 1

Author Comment

by:srithi
ID: 7049361
i did but it does not work still te same ,service gets strucked and never returns........
and i am unable to stop it even,


here is the code which i tried,

     CInternetSession *session;
     CFtpConnection *ftp;
     OutputDebugString("In Ftp Code Before Exception");
          try{
               session = new CInternetSession;
          ftp = session->GetFtpConnection(rules.sFTPInIP,rules.sFTPInUser,rules.sFTPInPassword);
          }
          catch(CInternetException *p)
          {
                         OutputDebugString("Exception Raised.............");
                         delete p;
                              return;
          }

i feel its failing when its trying to create CInternetSession object.
what to do ,plz help out.
thankx
0
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 7049699
So, the exception never gets caught?

Is your server running as "LocalSystem"? If so, set it to run under a differnt user, as "LocalSystem" has absolutely no network access rights - this could explain your problem...
0
 
LVL 1

Author Comment

by:srithi
ID: 7050465
i din't get you,
but let me explain the current situation,

i am working on a pc which is connected to a lan ,and i access the internet through the proxy,actually this service will run on server but what i want is, if it executed on some workstation then it should say that "u are not on the server hence you cannnot connect to the internet"
hope u understood my sitatuion,

thankx for your time.

 
0
 
LVL 86

Expert Comment

by:jkr
ID: 7051021
OK, which user account does the server run under? Is your server running as "LocalSystem"? If so, set it to run under a differnt user, as "LocalSystem" has absolutely *no* network access rights - this would explain your problem...
0
 
LVL 86

Expert Comment

by:jkr
ID: 7059099
Are you still there?
0
 
LVL 1

Author Comment

by:srithi
ID: 7061587
sorry i was on leave,i 'll get back soon
0
 
LVL 86

Expert Comment

by:jkr
ID: 7099538
*ping*
0
 
LVL 1

Author Comment

by:srithi
ID: 7100047
i am sorry for this delay ,as i was on leave for my post graduate exams ,anyhow,coming back to my problem ,i login on my machine with administrator login,it is not network,i browse the sites thru proxy ,what i want is when  the proxy is not there ,my service should give a message to debug view window saying that you are not connected to net.

thank for your time,plz co operate,i will finilze this Question very soon for sure.
0
 
LVL 1

Author Comment

by:srithi
ID: 7157771
sorry for the delay ,
i have been shifted to evc++ so i was busy with my projects,
thank you for your time.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7158430
>>i was on leave for my post graduate exams

Did everything go allright? .o)
0
 
LVL 1

Author Comment

by:srithi
ID: 7163665
yeah fine thank you ,
comming back to my service problem for now its left as it is,
if i struck sometime,hope you will come back.
thank you.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7163672
The problem and the answer will still be the same - set your service to run under a different account...
0
 
LVL 1

Author Comment

by:srithi
ID: 7163679
oh u are online,thats great,i will do that,thank you.
can we chat if u don't mind,just eager to talk to an expert,if u are free,my hotmail account is sesham_ss@hotmail.com
0
 
LVL 86

Expert Comment

by:jkr
ID: 7163697
>>can we chat if u don't mind

Sorry, but I don't have any IRC SW installed, and, BTW, it is 3:10am here, so I am not really into starting a chat... more like goung to bed <s>
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question