Solved

points for jkr

Posted on 2002-05-30
19
240 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
  • 10
  • 9
19 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
How are you handling the exception?
0
 
LVL 1

Author Comment

by:srithi
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:srithi
Comment Utility
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
Comment Utility
You should at least delete the exception, as I pointed out above...
0
 
LVL 1

Author Comment

by:srithi
Comment Utility
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 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 86

Expert Comment

by:jkr
Comment Utility
Are you still there?
0
 
LVL 1

Author Comment

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

Expert Comment

by:jkr
Comment Utility
*ping*
0
 
LVL 1

Author Comment

by:srithi
Comment Utility
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
Comment Utility
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
Comment Utility
>>i was on leave for my post graduate exams

Did everything go allright? .o)
0
 
LVL 1

Author Comment

by:srithi
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now