![]() |
writing a service in VB.NET
I have an existing c++ (actually, g++) program that registers as a service - and then - while running - reacts to the presence of a text file. Depending on the content of the lines in the text file - the service will do one of two things:
1) start a new process - running a batch file created by the internet user via an ASP page. --Or-- 2) send a small TCP/IP packet to a UNIX machine which has a companion daemon listening for the imcoming packet. I'm trying to port this existing code to VB.NET. The two winapi functions that the existing service uses are these: :
if (LogonUser((LPTSTR)UserName, (LPTSTR)Domain, (LPTSTR)Passwd, :
if (CreateProcessAsUser(hUserHandle, NULL, (CHAR*)line.c_str(),The problem is - I cannot get the second function to work in VB.NET - I've tried just about every variation on this system call - searched the web for examples - and haven't found anything that will get this last function to work. Here's one example of the VB function declaration and the call that I've tried. To no avail. :
Public Declare Auto Function CreateProcessAsUser Lib "advapi32.dll" ( _:
Dim saProc As SECURITY_ATTRIBUTES = New SECURITY_ATTRIBUTES(We're still using vb.net from VS 2003 - so the new 'process class' that came out with the 2.0 framework isn't available to me for this project. :-( ) |
Re: writing a service in VB.NET
maybe download VB Express, for free, from Microsoft? They recently release the 2008 version so you may find what you're looking for there. It's free, so what have you got to lose really?
|
Re: writing a service in VB.NET
Only compatibility with the other programmers in the company - we have decided to remain on the 2003 edition of visual studio - at least for now - so I'm pretty stuck with that.
(I did download and install the c# freebie from Microsoft from VS 2008 - and it's pretty neat - but I'm not permitted to use that for code I have to check in. Alas.) |
Re: writing a service in VB.NET
Is a complete rewrite necessary? You could wrap problematic bits in a C++ library project. It really depends on the "why" and "how much" of this rewrite effort.
|
Re: writing a service in VB.NET
Quote:
The department I currently program for - has had many programmers over the past several years. Each has brought his/her own unique strengths to the job. Programs written during the tenure of Mr. A tended to be Gnu c++(g++). Written and compiled on various platforms - Linux/UNIX/Windows. Programs written during the tenure of Mr. C tended to be ASP/ASP.NET. Programs written during the tenure of Ms. D tended to be Gnu C (gcc). Written and compiled on LINUX platforms with libraries for Windows linked in when needed. I am wanting to get all of these legacy programs updated into the Visual Studio language that's appropriate to each task - and appropriate to my own coding ability. And, in so doing - the code will be more maintainable. (There are only two programmers on staff that can really deal with this old/legacy c++ code. Everyone else is a .NET programmer of some kind. If I get this code into a mainstream source VB.NET, VC#, VC++ - then it will be more readily modifiable. (I currently have 3 different versions of Gnu c++ compilers - and they don't co-exist very well - so I have them loaded on three different machines. For one of the applications - I have to use machine A ... for another application, Machine B, and so on...) The bottom line - this function - the one I'm trying to get to work - I wrote a VC# project and this same function won't work from there, either. I did not try this in VC++, though - I suppose I could. |
Re: writing a service in VB.NET
Quote:
check it out http://msdn2.microsoft.com/en-us/lib...ss(VS.71).aspx namespace it is under is system.diagnostics |
| All times are GMT -5. The time now is 2:20 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC