|
Hiya all.
I use advapi32.dll via VB.net to install a service, however I do not seem to think it goes as well as I'd like.
Often when I run the install, everything seems to indicate that it succeedes, but I can't find the service in neither my service list nor registry - although if I use the ServiceController class, I can get a status out on the service.
Similar when I attempt to start or stop the service, the code seems to run fine, but .... alas no service work seems to be done.
Lastly - I am having problems, again similar, with uninstalling - and about 50/50 I either can or can not uninstall (meaning the code runs through fine or not), yet because I can not see my service in the list when installed - I have no visible proof it is uninstalled other then the ServiceController class crashes if I try to get status.
This is the code I am using (VB.NET ... sorry, my company uses that instead of C# )
<br />
Private Declare Auto Function OpenSCManager Lib "advapi32.dll" (ByVal strMachineName As String, ByVal strServiceControllerDB As String, ByVal intServiceController As Integer) As IntPtr<br />
Private Declare Auto Function CreateService Lib "advapi32.dll" (ByVal SCHANDLE As IntPtr, ByVal strServiceName As String, ByVal strDisplayName As String, _<br />
ByVal intDesiredAccess As Integer, ByVal intServiceType As Integer, ByVal intStartType As Integer, ByVal intErrorControl As Integer, ByVal strServicePath As String, _<br />
ByVal strLoadOrderGroup As String, ByVal intTagId As Integer, ByVal strDependencies As String, ByVal strServiceStartName As String, ByVal strPassword As String) As IntPtr<br />
Private Declare Auto Sub CloseServiceHandle Lib "advapi32.dll" (ByVal SCHANDLE As IntPtr)<br />
Private Declare Auto Function StartService Lib "advapi32.dll" (ByVal SVHANDLE As IntPtr, ByVal intNumServiceArgs As Integer, ByVal strServiceArgVectors As String) As Integer<br />
Private Declare Auto Function OpenService Lib "advapi32.dll" (ByVal SCHANDLE As IntPtr, ByVal strServiceName As String, ByVal intNumServiceArgs As Integer) As IntPtr<br />
Private Declare Auto Function DeleteService Lib "advapi32.dll" (ByVal SVHANDLE As IntPtr) As Integer<br />
Private Declare Auto Function GetLastError Lib "advapi32.dll" () As Integer<br />
Private Declare Function ControlService Lib "advapi32.dll" (ByVal SVHANDLE As IntPtr, ByVal intControl As Integer, ByVal objServiceStatus As SERVICE_STATUS) As Integer<br />
<br />
Friend Function InstallService(ByVal strServicePath As String, ByVal strServiceName As String, ByVal strServiceDisplayName As String) As Boolean<br />
Try<br />
'Get handle to Service Control Manager<br />
Dim SCMHANDLE As IntPtr = OpenSCManager(Nothing, Nothing, SC_MANAGER_CREATE_SERVICE)<br />
If SCMHANDLE.ToInt32 <> 0 Then<br />
'Get Handle to Service<br />
Dim SERVICEHANDLE As IntPtr = CreateService(SCMHANDLE, strServiceName, strServicePath, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, strServiceDisplayName, Nothing, 0, Nothing, Nothing, Nothing)<br />
If SERVICEHANDLE.ToInt32 <> 0 Then<br />
If StartService(SERVICEHANDLE, 0, Nothing) <> 0 Then<br />
'Service started, close handler.<br />
CloseServiceHandle(SCMHANDLE)<br />
Return True<br />
Else<br />
'Service could not be started. Service could be running as well ( or installed?)<br />
Return False<br />
End If<br />
Else<br />
'Service handler could not be opened.<br />
End If<br />
Else<br />
'Service Control manager could not be opened.<br />
Return False<br />
End If<br />
Catch ex As Exception<br />
Throw ex<br />
End Try<br />
End Function<br />
<br />
Friend Function Uninstall(ByVal strServiceName As String)<br />
Dim GENERIC_WRITE As Integer = &H40000000<br />
'Get handle to Service Control Manager<br />
Dim SCMHANDLE As IntPtr = OpenSCManager(Nothing, Nothing, GENERIC_WRITE)<br />
'Get Handle to Service<br />
If SCMHANDLE.ToInt32 <> 0 Then<br />
Dim DELETE As Integer = &H10000<br />
Dim SERVICEHANDLE As IntPtr = OpenService(SCMHANDLE, strServiceName, DELETE)<br />
If SERVICEHANDLE.ToInt32 <> 0 Then<br />
If DeleteService(SERVICEHANDLE) <> 0 Then<br />
'Service deleted<br />
CloseServiceHandle(SCMHANDLE)<br />
Return True<br />
Else<br />
'Service could not be deleted<br />
CloseServiceHandle(SCMHANDLE)<br />
Return False<br />
End If<br />
Else<br />
'Service handler could not be opened.<br />
Return False<br />
End If<br />
Else<br />
'Service Control manager could not be opened.<br />
Return False<br />
End If<br />
End Function<br />
<br />
The code is a piecing of stuff I found off the net and some decompiling.
Can anybody advice me as to what I'm doing wrong, or is this method of controlling service installation buggy. I really would preferer such a method as this as I do not really want to call Shell and instalutil
Regards.
|
|
|
|
|
How can I update my database by making changes in changes in my xml file? Could someone reply?
samita
|
|
|
|
|
How does one get the assembly's Namespace Name?
I embedded some SQL scripts in an assembly. The assembly name is "AAI_TK1", it is in the "ArchiveXpress20" namespace.
Dim asm As System.Reflection.[Assembly] = System.Reflection.[Assembly].GetExecutingAssembly()
--> this returns "AAI_TK1" ----> asm.GetName().Name
However the Resource names are prefixed with the namespace
--> "ArchiveXpress20.Script1.SQL" ----> GetManifestResourceNames()
I didn't want to hardcode the namespace. How can you get your namespace?
|
|
|
|
|
Hi,
I recently had the same problem. My solution so far is creating an object OBJ
of a type defined in the same namespace, and then use OBJ.GetType().NameSpace
I too would prefer a simpler solution...
-- modified at 17:10 Thursday 7th December, 2006
Luc Pattyn
|
|
|
|
|
By initializing an 'XmlSerializer' object, you must specify what type of object you will serialize.
Any idea why you must do this by using an 'XmlSerializer' and not when you are using a 'BinaryFormatter' or any other formatter?
-- modified at 7:00 Friday 8th December, 2006
|
|
|
|
|
I have an enterprise template project on VC7 .NET.
When I enter the "Configuration manager" , I see that in Debug configuration one of the projects is not checked in the "Build" column, and thus this project is not compiled when I am building the solution. I check the project in the Build column, close the configuration manager window. The build solution now includes also the project that was not checked. But when I close and reopen the sln, this information is lost and the configuration manager window shows that project as unchecked.
This seems as a bug of the studio . . . ?!!???, is there a way to make my solution configuration to include unchecked project also?
Thanks in advance,
Julia.
|
|
|
|
|
Hi,
I want to encrypt soap username and password.
right now i only authenticate username and password.
in Webservice:
public class Authentication : SoapHeader
{
public string Username;
public string Password;
}
public class Service : System.Web.Services.WebService
{
public Authentication authenticate;
public Service () {}
[WebMethod]
[SoapHeader("authenticate", Required = true)]
public string DataManupulation(string InputXML)
{
// Forming OutputXML
return Ouput XML
}
}
in Client:
I'm creating object and passing SOAP Header,
now i want to pass encrypted SOAP header.
Can any one help me? Its very urgent.
Thanks in advance
Poongodi
|
|
|
|
|
|
Hi all listeners,
I want to receive two files in a orchrestration from differnet
locations(diferetnt sharepoint sites) and want to construct one of it
accordig to the other.
The scenario is:
first locatuion have number of (around 50) files containing "id" and "rank"
field in each file along with other fields.
I want to create a file containing a heading title and one record for each
file from first location listing "id" and "rank" for each file.
I am plannig for a flow for each file at first location, after this file is
received orch. will fech that "Rank" file from 2'nd location and append one
record for the received file from 1st location.
So i need 2 receive shapes and corrosponding ports.
I have defined correlation set for orch. and initialised it ...now its
giving me error:
"""" In a sequetial convoy the ports must be identical. """
"""" But i want tow diiferent ports for differet loccations
""""
What should i do???
And redig the scenario ...if u have some idea to solve it...please share it
with me...
Waiting for reply......
Mahavir.
|
|
|
|
|
Does anyone have conclusive evidence as to wether or not a .NET application can make use of the App Paths registry key? I created a tentative test app and it doesn't seem to find the additional DLLs, but I wanted to get some corroboration.
Thanks,
Scott.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Yes, it can be done. Post your code fragment here, and we can see what's not working.
|
|
|
|
|
ednrgc wrote: Post your code fragment here
I would but I don't think the problem is in the code.
I have an application that uses some common DLLs that could potentially be shared by some of our other products. Ideally, we would strong-name these DLLs and put them in the GAC, but (at least right now) I'm not allowed to do that. The next best thing would be to install the shared DLLs to a common folder.
In the installer (InstallShield 12), I create the following registry key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Console.exe
(The name of the app in this case is "Console.exe")
and then create a Path string value with the following data:
C:\Program Files\Company\Product\; C:\Program Files\Common Files\Company
When I try to run Console.exe, I get an error saying that it can't find one of the required components. If I copy the DLLs from the common folder back to the local application folder, everything works properly.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I have a problem with VB and graphic. I can generate all the graphics i want but saving is only possible in bitmap.
I need to scale and modify the output of my software with AI or Corel Draw but do not get results. Vectorizing is not an option. I tried various vectorizer lice Corel Trace and the results are not what i expect.
Helmut Ehrhardt (Ghana)
|
|
|
|
|
asestar wrote: I tried various vectorizer lice Corel Trace and the results are not what i expect.
Have you found a solution to the problem?
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
No, i still do not have a clue.
|
|
|
|
|
Hi,
i want to ask can i call a crystal report without reportViewer control. i mean is there any way to call a report directly in some way??
basically i'm using c# express edition which do suports SQL server 2005 but doesnt support crystal reports. so i installed crystal report 10 seperately and begin using it. now in my C# IDE if i go to add Item then crystal report icon doesn't apear. also there is not report viewer control in the the controls area. so i asked this question. if there exists no way then sugest me what should i d0??
hope u'l respond for my satisfaction.
as far as my introduction is concerned i'm a student of BS doing my final project, i'm using .net since 1 year but crystal reports are new for me.
regards
thx in advance!!
regards
shaz jazz
|
|
|
|
|
hi there.
report viewer control is a part of dll so you wouldn't be ablt o use it serperately. there might be some other options, but here is a rough-one.
export the report to a file of desired format and then view in explorer or other application that supports the
format you chose.
Rep r = new Rep(); //report object
r.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat , "C:\\myreport.pdf"); //exporting as pdf file
ProcessStartInfo info = new ProcessStartInfo("iexplore.exe","C:\\myreport.pdf");
Process.Start(info);
if you cant find something more robust, this may be usefull, at least on educational level.
regards.
|
|
|
|
|
guys..
i'm getting this error from the event viewer log.
Event ID:1000
description as below..
Faulting application erss.winui.exe, version 1.0.0.0, stamp 45742a0c, faulting module mscorwks.dll, version 2.0.50727.42, stamp 4333e7ec, debug? 0, fault address 0x0006d580.
byte data as below..
0000: 41 00 70 00 70 00 6c 00 A.p.p.l.
0008: 69 00 63 00 61 00 74 00 i.c.a.t.
0010: 69 00 6f 00 6e 00 20 00 i.o.n. .
0018: 46 00 61 00 69 00 6c 00 F.a.i.l.
0020: 75 00 72 00 65 00 20 00 u.r.e. .
0028: 20 00 65 00 72 00 73 00 .e.r.s.
0030: 73 00 2e 00 77 00 69 00 s...w.i.
0038: 6e 00 75 00 69 00 2e 00 n.u.i...
0040: 65 00 78 00 65 00 20 00 e.x.e. .
0048: 31 00 2e 00 30 00 2e 00 1...0...
0050: 30 00 2e 00 30 00 20 00 0...0. .
0058: 34 00 35 00 37 00 34 00 4.5.7.4.
0060: 32 00 61 00 30 00 63 00 2.a.0.c.
0068: 20 00 69 00 6e 00 20 00 .i.n. .
0070: 6d 00 73 00 63 00 6f 00 m.s.c.o.
0078: 72 00 77 00 6b 00 73 00 r.w.k.s.
0080: 2e 00 64 00 6c 00 6c 00 ..d.l.l.
0088: 20 00 32 00 2e 00 30 00 .2...0.
0090: 2e 00 35 00 30 00 37 00 ..5.0.7.
0098: 32 00 37 00 2e 00 34 00 2.7...4.
00a0: 32 00 20 00 34 00 33 00 2. .4.3.
00a8: 33 00 33 00 65 00 37 00 3.3.e.7.
00b0: 65 00 63 00 20 00 66 00 e.c. .f.
and right before this error i'm also getting the .Net Runtime error and it says
.NET Runtime version 2.0.50727.42 - serious runtime engine error(7A05E2B3) (80131506)
my application is running on the .Net Framwwork 2.0 and it's a winform application...
i'm not pretty sure but after this errors i also get the application hang. it just stops and the it dies...
please help...
|
|
|
|
|
|
I am doing performance measurements and would like to use a native executable to avoid having JITs occur during performance timing. How does one execute an ngen-generated executable?
There are blogs and MS documentation everywhere that talk about how to use ngen, but I have not found a single place that says how to execute an ngen-executable!
Here is what I tried. Compile:
% csc helloworld.cs
Then install in the global assembly cache:
% ngen install helloworld.exe
Then go to the assembly cache and try to execute:
% cd c:\windows\assembly\helloworld\[hex string]
% ./helloworld.ni.exe
This gives the error message: c:\windows\assembly\helloworld\[hex string\helloworld.ni.exe is not a valid WIN32 application.
|
|
|
|
|
If I remember correctly, you still run the "normal" helloworld.exe file. The runtime will figure out that you have a corresponding native image and use that instead.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I tried that before posting - I don't think it works. The md5 sum of helloworld.exe is unchanged by running "ngen install helloworld.exe".
|
|
|
|
|
We have various enumerated types in our system and we obviously want to present human readable values that can be easily configured by our UI folks rather than the cryptic identiofiers that we use in the code.
Just wondering what facilities are available in .NET 3.0 to accomodate this kind of thing. In the old days, I would use a string resource and a mapping table for the lookup.
Anybody got any cool/slick/modern ideas on this?
Thanks
NIK
|
|
|
|
|
The following will print "Blue" to the console:
namespace CSFoo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(ETest.Blue);
}
}
enum ETest
{
Red,
White,
Blue
}
}
|
|
|
|
|
I need to provide a secondary string description of the enum value.
Rather than "Blue", I would want to map that value to a human friendly string such as "The Color Blue".
Make sense?
|
|
|
|
|