Solved

points for jkr

Posted on 2002-05-30
19
256 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
Independent Software Vendors: 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

690 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