logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
CreateProcess API

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Fri Nov 25, 2005 14:58    Post subject: CreateProcess API Reply with quote

Hi here.

I have a problem with the Kernel32 api CreateProcess.

The follow discussion has been copied from bioware's forums :

Quote:

I have developed an application that allows to restart nwnx by remote.

But there is an error, when i call CreateProcess API To run nwnx (it seems the only api which starts nwnx correctly) nwserver gives error: "Could not estabilish network comunication, port may be in use".

But nwserver shows that error for everyport that i set in the ini file.I have also tried with command-line -port xxx.

Thanks in advance.



Does anyone knows where is the error? I used VB6.

Holavez
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Tue Nov 29, 2005 14:36    Post subject: Reply with quote

Hard to tell.. does NWNX show the correct port and module name ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Tue Nov 29, 2005 17:10    Post subject: Reply with quote

Yes. it shows them correctly.

The server does not load the correct port from the ini file...it sets port "-1" and leave the ip-box empty.

It also does not load the module...

I tested with version 2.5.3.


Holavez
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Wed Nov 30, 2005 10:23    Post subject: Reply with quote

Could be a path related problem... on the other hand, if nwnx is able to start nwserver, it should already be in the correct directory.

Did you try something simple like ShellExecute ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Wed Nov 30, 2005 18:43    Post subject: Reply with quote

Yes i did.Shell, ShellExecute, ShellExecuteEx, WinExec, don't start nwserver.

With those api it runs correctly, but nwnx does not start nwserver.

However i tried to execute a separate istance of nwserver with an other shell, and, when it goes down nwnx doesn't restart the server.

I don't be able to find the problem...Do you want to see the exec code?

Holavez
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Wed Nov 30, 2005 21:14    Post subject: Reply with quote

Yes, please post it. I guess there is some problem with parameter passing.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Wed Nov 30, 2005 22:22    Post subject: Reply with quote

Api Declaration code
Code:

Public Const NORMAL_PRIORITY_CLASS = &H20
Public Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type

Public Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
End Type

Public Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessId As Long
        dwThreadId As Long
End Type

Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long


Exec code
Code:

Dim bProcess As Long
Dim sec As SECURITY_ATTRIBUTES
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
bProcess = CreateProcess(txNWNXPath.Text, " -module " & txModName.Text, sec, sec, 0, NORMAL_PRIORITY_CLASS, 0, Left(txNWNXPath.Text, Len(txNWNXPath.Text) - 9), start, proc)


This is the code.

Holavez
Back to top
View user's profile Send private message
dumbo



Joined: 21 Aug 2005
Posts: 21

PostPosted: Fri Dec 02, 2005 8:55    Post subject: Reply with quote

i dont know vb Wink

1. zero-fill STARTUPINFO struc (start)
2. start.cb = sizeof(STARTUPINFO)
3. bProcess = CreateProcess(txNWNXPath.Text, " -module " & txModName.Text, 0, 0, 0, NORMAL_PRIORITY_CLASS, 0, Left(txNWNXPath.Text, Len(txNWNXPath.Text) - 9), start, proc)
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Fri Dec 02, 2005 12:19    Post subject: Reply with quote

Hmm, what happens when you ommit the path parameter and run your .exe right in the NWN directory ? This is how nwnx does it.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Fri Dec 02, 2005 17:38    Post subject: Reply with quote

@Papillon : Nothing...it gives the same error.

However i have also tried to run a .bat file with the nwnx path, and it doesn't start nwserver.

With 0 passed by paramter to the CreateProcess function, vb gives a compilation error...

I think the problem is vb Sad.

Holavez
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Dec 05, 2005 3:56    Post subject: Reply with quote

dumbo wrote:
i dont know vb Wink

1. zero-fill STARTUPINFO struc (start)
2. start.cb = sizeof(STARTUPINFO)
3. bProcess = CreateProcess(txNWNXPath.Text, " -module " & txModName.Text, 0, 0, 0, NORMAL_PRIORITY_CLASS, 0, Left(txNWNXPath.Text, Len(txNWNXPath.Text) - 9), start, proc)


Does you ModName include a space?
Might be best to make the entire -module parameter into a string, and enquote the ModName

eg " -module "_"My Mod"_"_" _'s only for emphasis on the quoting (they are not included)

Gryphyn
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group