Solved

points for jkr

Posted on 2002-05-30
19
245 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 200 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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