hexagon logo

Program to Open PC-DMIS

I am currently attempting to write a program (VB.NET) that will have a PC-DMIS program's file name passed to it. This program should then start PC-DMIS if it isn't already running, and open the program that was passed to it. If PC-Dmis is already running, then it should open the program that was passed to it. Then, the program should close, leaving PC-DMIS running. I also want PCDMIS to be opened as Operator Mode.

I am attempting to do this by referncing PCDLRN within the program. Hwoever, I am having little luck with the .OperatorMode=true method.

The reason I am attempting to do this in VB.NET is I will then follow up with some additional programming (saving info to a DB and what not) that would be cumbersome as a .VBS etc.

This PCDMIS 2011 MR1 and VB.NET 2010 (.NET 4.0)

Imports System.IO


Public Class Form1

    Public PCDApp As PCDLRN.Application
    Public PCDPartPrograms As Object
    Public PCDPartProgram As Object

    Public fileName As String = "C:\Work\31580 - 1 - 12345.PRG"


    Private Sub Application_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        If File.GetAttributes(fileName) = FileAttributes.ReadOnly Then
            File.SetAttributes(fileName, FileAttributes.Normal)
        End If

        StartApplication(fileName)

    End Sub ' Application_Load



    Public Sub StartApplication(ByVal _fileName As String)

        PCDApp = CreateObject("PCDLRN.Application")
        PCDPartPrograms = PCDApp.PartPrograms

        PCDApp.Visible = True
        PCDPartPrograms.Open(_fileName, "CMM1")

    End Sub


End Class
  • To the Chinese, I can help you.


    But not any other nationalities/people? GTFO!
  • I suppose you tried adding the line
    PCDapp.OperatorMode = True

    after
    PCDApp = CreateObject("PCDLRN.Application")

    ?

    That definitely works with VBA in Excel 2010. Fascinating - I can switch PC-DMIS in and out of Operator mode without exiting! Opens new vistas for my own controlling program (written in Delphi Pascal).
  • Fascinating - I can switch PC-DMIS in and out of Operator mode without exiting! Opens new vistas for my own controlling program (written in Delphi Pascal).


    That must be a bug - no? Wink
  • As soon as I have the PCDApp.OperatorMode = True in there, I receive the following error:

    ************** Exception Text **************
    System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at PCDLRN.IApplication.set_OperatorMode(Boolean Param)
       at PCDMIS_Handler.Form1.StartApplication(String _fileName) in C:\Projects\PCDMIS_Handler\Form1.vb:line 30
       at PCDMIS_Handler.Form1.Application_Load(Object sender, EventArgs e) in C:\Projects\PCDMIS_Handler\Form1.vb:line 20
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
  • Hmm, interesting enough.... it only throws that error when I run the project from with in Visual Studio. However, if I run the compiled .EXE, it seems to work just fine.

    Or it may have to do with the fact that PC-DMIS isn't ready yet. I think I should try a loop that waits 2 seconds and checks to see if the Object exists. If not, it waits another 2 seconds.
  • Assign the operator mode toggle to a button on your form, let PC-DMIS start up and then hit the button.

    PC-DMIS takes a while to rev up...
  • Start Me Up
    Start Me Up lyricsSongwriters: Jagger, Mick; Richards, Keith;


    If you start me up
    If you start me up I'll never stop
    If you start me up
    If you start me up I'll never stop


    I've been running hot
    You got me ticking gonna blow my top
    If you start me up
    If you start me up I'll never stop
    Never stop, never stop, never stop


    You make a grown man cry
    You make a grown man cry
    You make a grown man cry
    Spread out the oil, the gasoline
    I walk smooth, ride in a mean, mean machine
    Start it up


    If you start it up
    Kick on the starter give it all you got, you got, you got
    I can't compete with the riders in the other heats
    If you rough it up
    If you like it you can slide it up
    Slide it up, slide it up, slide it up


    Don't make a grown man cry
    Don't make a grown man cry
    Don't make a grown man cry
    My eyes dilate, my lips go green
    My hands are greasy, she's a mean, mean machine
    Start it up


    Start me up
    Give it all you got
    You got to never, never, never stop
    Slide it up, baby just slide it up
    Slide it up, slide it up, never, never, never


    You make a grown man cry
    You make a grown man cry
    You make a grown man cry
    Ride like the wind at double speed
    I'll take you places that you've never, never seen


    Start it up
    Love the day when we'll never stop, never stop
    Never, never, never stop
    Tough me up
    Never stop, never stop


    You, you, you make a grown man cry
    You, you make a dead man come
    You, you make a dead man come


  • Can't you just register the .PRG extension to open with Pcdmis.exe /o (operator switch)? Won't this open Pcdmis and the program (in operator mode) if Pcdmis isn't open and open the program if Pcdmis is already open?