Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

win services using C++

Last post 03-25-2008 8:25 AM by K++. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-18-2008 7:05 AM

    win services using C++

     i wrote a service using c++ which periodically checks the internet connection and when internet connection establishes to the system then it invokes an executable file (written in VB) , this executable file collects database from the web site and compares it with the local database for new updates.

     

    my problem is . . .  .

    when i run the executable file by double clicking on it , it is performing well.

    but when i run it by services(which i wrote using c++) this executable is not connecting to the web site, i used shell execute command to run the executable file.

    i used this command. . . 

    ShellExecute(NULL, "open","C:\VUpdate.exe", NULL,NULL, 1);

     

    any body help me ..... 

    • Post Points: 15
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 02-18-2008 3:46 PM In reply to

    Hmm [^o)] Paths ?!

    => Is your EXE file being executed ? if not, what's the return value of 'ShellExecute()' (that will specify the error) ?

    => You should use "C:\\" instead of "C:\" :

    ShellExecute( NULL, L"open", L"C:\\VUpdate.exe", NULL, NULL, SW_SHOWNORMAL );

    The above statement will run the EXE file. Also try 'system()' (or 'CreateProcess()') :

    system( "C:\\VUpdate.exe" );

    => A common problem is, when you run an EXE file yourself (by double clicking), The default directory is that the EXE file exists in that, but when a program runs the EXE file the default directory may change to that the caller app exists on. Then check the paths that you are using in your EXE file.

    => Anyway, explain more about what the EXE file performs, and what are the errors exactly.

    - My weblog
    - NetTimeSaver : My software that logs your connecting informations (like duration).
    Filed under: ,
    • Post Points: 10
  • 02-20-2008 4:55 AM In reply to

    Re: Paths ?!

    Requirement:
    -------------
    we are developing Accounting packages and we used to release periodical updates(patches) for these packages which we keep in the web site, customer has to download there patches and has to install them.

    while installing these patches customer is facing problems. so to rectify this problem we have planned for auto updation just like windows updates.

     

    Process:
    --------
    A service will running on the customer system which periodically checks the internet connection , when the connection establishes it runs an executable file which will opens  local database consists of latest files (present in the system) information and downloads the latest files (files ready for download from website) information database from website.

    it compares both databases if any new files information exists it updates into the localdatabase and starts downloading the files from web site, after downloading all the files it performs the necessary operations to be performed to run the package.

     

    Development:
    ------------
    i wrote service stuff in VC++

    and the exectable stuff in VB and the database is .mdb MSACCess file

     

    Problem*-******
    ---------
    I Installed Service it is running well , and opening the exectutable file when the internet connection establishes to the system (so it means service it is working well till here)

    i can see both service file and executable file in the task manager

    the executable file is opening the local database and next it start trying to collect the database from the web site, here it stops working , it is not returning any message and not logging any thing.

    when i run the executable file directly by double clicking on it , it is performing all the functions(opening the local databse , collecting the databse from website, updating the database and downloading all the files)

    i even tried by running the executable file from command prompt here also it is working well.

    i am facing problem only when i try it from Service.


    command i used to open the executable file is :
    ShellExecute(NULL, "open","C:\VUpdate.exe", NULL,NULL, 1);

    • Post Points: 10
  • 02-20-2008 5:13 PM In reply to

    Confused [*-)] Obscure!

    => You can try :

    ShellExecute( NULL, "open", "C:\\VUpdate.exe", NULL, "path of EXE file", SW_SHOWNORMAL );

    - My weblog
    - NetTimeSaver : My software that logs your connecting informations (like duration).
    • Post Points: 5
  • 03-25-2008 8:25 AM In reply to

    • K++
    • Not Ranked
    • Joined on 07-05-2007
    • Tunisia
    • New Member
    • Points 45

    Re: win services using C++

     Warning! Your service program executes under Windows NT, this means that is has many security right has not some too!

    It means that you must ensure the following:

    1. Your service gets executed: this is trivial to do, just give the right executable name for "CreateProcess"  function and the work is done for you.

    2. Your service has the "privileges" to access the network, for that it should be run under "NETWORK SERVICE" user account which is a system hidden account created specially for services requiring access to the network, which is your case. If necessary, you may use "AdjustTokenPrivileges" to add the privileges you need.

    From my view point, you would better use ready technologies: don't you know BITS (Background Intelligent Transfer Service)? It is a very good service that allows you to download the files you want from the network and can handle network heavy loads, connection interruptions and more... If I were you, I would use that service to download the files I want then use the application to compare the data bases. So this way, I will not break my head just because "my service" does not function as expected!

    Nice day! 

    He who never make mistakes, makes nothing...
    • Post Points: 5
Page 1 of 1 (5 items)