Solved

points for jkr

Posted on 2002-05-30
19
252 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 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 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