Topic
  • 6 replies
  • Latest Post - ‏2016-01-14T13:22:06Z by EHcnck
SystemAdmin
SystemAdmin
3180 Posts

Pinned topic how to call an existing JAVA/C api or console command in DXL

‏2011-11-10T02:36:08Z |
Hi all,

I am now trying to integrate DOORS with my own application, and there are two questions may need your support.
1.Is it possible to execute a console command such as "dir" in DXL and parse the output of dir into DXL for later usage?
2.If I have a set of existing java/c api, how to call these apis in DXL and leverage the return value in DXL?

thanks
Updated on 2011-11-10T13:28:32Z at 2011-11-10T13:28:32Z by Mathias Mamsch
  • OurGuest
    OurGuest
    163 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2011-11-10T11:40:16Z  
    Search for following command on this forum: win32SystemWait_
  • Mathias Mamsch
    Mathias Mamsch
    2183 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2011-11-10T13:28:32Z  
    1. For the executing of command line you can use system, win32SystemWait_ or the attached shell library, which also enables terminating a started application or getting its output (test code in library).

    2. Leveraging an existing C API from DXL is impossible without very dirty hacks. Interfacing a Java API? Well maybe in "DOORS Next Generation ...". What you always can do is create a COM server in some language of your choice, which will then interface to your APIs. You can then use the COM server to interface to your applications. This can be done quickly, however you need some experience in COM server programming to "get it right".

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • jester76
    jester76
    68 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2013-10-25T00:40:38Z  
    1. For the executing of command line you can use system, win32SystemWait_ or the attached shell library, which also enables terminating a started application or getting its output (test code in library).

    2. Leveraging an existing C API from DXL is impossible without very dirty hacks. Interfacing a Java API? Well maybe in "DOORS Next Generation ...". What you always can do is create a COM server in some language of your choice, which will then interface to your APIs. You can then use the COM server to interface to your applications. This can be done quickly, however you need some experience in COM server programming to "get it right".

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

    Hello,

    It would be neat if the shell/command windows can be hid. 

    Thanks

    Jester

  • Mathias Mamsch
    Mathias Mamsch
    2183 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2013-10-25T10:32:41Z  
    • jester76
    • ‏2013-10-25T00:40:38Z

    Hello,

    It would be neat if the shell/command windows can be hid. 

    Thanks

    Jester

    Please note that there are NO shell windows appearing, when using shell.inc to start Notepad. If there is a shell window appearing when you are using shell.inc to run something it may be, that you are running a console application (that is by itself creating a console to output stuff). The normal OS start process functions do not suppress the console of console applications when you run them. For this you need to start your console application over a separate tool, that will block the console. Details on your favorite search engine, e.g. see here: http://www.codeproject.com/Articles/2537/Running-console-applications-silently

    Alternatively if you are running a tool, that you created yourself, just link it as a non console application.

    Regards, Mathias

    Updated on 2013-10-25T10:33:34Z at 2013-10-25T10:33:34Z by Mathias Mamsch
  • Mathias Mamsch
    Mathias Mamsch
    2183 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2013-10-25T10:51:26Z  

    Please note that there are NO shell windows appearing, when using shell.inc to start Notepad. If there is a shell window appearing when you are using shell.inc to run something it may be, that you are running a console application (that is by itself creating a console to output stuff). The normal OS start process functions do not suppress the console of console applications when you run them. For this you need to start your console application over a separate tool, that will block the console. Details on your favorite search engine, e.g. see here: http://www.codeproject.com/Articles/2537/Running-console-applications-silently

    Alternatively if you are running a tool, that you created yourself, just link it as a non console application.

    Regards, Mathias

    It seems the WScript OLE object also allows you to start an application without a window. So in this case, you have to use the "Run" method instead of the exec method and pass 0 (hide) as a second argument. But in this case you cannot get the output of the process or terminate it, so that is something that cannot be patched in shell.inc. So something like this should get you started:


        OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
        OleAutoObj result = null
        
        OleAutoArgs args = create()
        
        put(args, "CMD /C CD /D C:\\ & DIR /S")
          put(args, 0)
          put(args, true)
        
        print oleMethod(shellObj, "Run", args , result)

    Regards, Mathias

  • EHcnck
    EHcnck
    110 Posts

    Re: how to call an existing JAVA/C api or console command in DXL

    ‏2016-01-14T13:22:06Z  

    It seems the WScript OLE object also allows you to start an application without a window. So in this case, you have to use the "Run" method instead of the exec method and pass 0 (hide) as a second argument. But in this case you cannot get the output of the process or terminate it, so that is something that cannot be patched in shell.inc. So something like this should get you started:


        OleAutoObj shellObj = oleCreateAutoObject "WScript.Shell"
        OleAutoObj result = null
        
        OleAutoArgs args = create()
        
        put(args, "CMD /C CD /D C:\\ & DIR /S")
          put(args, 0)
          put(args, true)
        
        print oleMethod(shellObj, "Run", args , result)

    Regards, Mathias

    when I run the above code I get the following error any ideas what maybe the cause?:

     

    OLE problem: , OLE error code: -2147024891