CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2006
    Posts
    42

    Unhappy Mscomm not working in Windows7 64 bit

    Dear all,
    I have a perfectly well running code in Windows XP .Net Studio 2005. When I copied and tried to run the code in the Windows 7 64 bit .Net Studio 2005 it gives error Exception from HRESULT:0x800A1F42. This exception is where I have declared the MsCOMM.
    Public Function InitComm() As Boolean
    Try
    With commport
    If .PortOpen = True Then
    .PortOpen = False
    End If
    .DTREnable = True
    .Handshaking = MSCommLib.HandshakeConstants.comNone
    .NullDiscard = False
    .CommPort = comport
    .Settings = "9600,e,8,1"
    .OutBufferSize = 1024
    .InBufferSize = 1024
    '.InputMode = 0
    .InputMode = MSCommLib.InputModeConstants.comInputModeBinary
    .InBufferCount = 0
    .OutBufferCount = 0
    If .PortOpen = False Then
    .InputMode = MSCommLib.InputModeConstants.comInputModeBinary
    .InBufferSize = 1024
    .PortOpen = True
    End If
    End With

    Catch ex As Exception
    MsgBox(ex.Message & " at " & "PmxComm.InitComm")
    End Try

    End Function

    This comes when comm is not registered. But I have registered both in sysWoW64 and System32. Still not working, please help.
    Yogi

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Mscomm not working in Windows7 64 bit

    Try

    Code:
    WinRS.exe /?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2006
    Posts
    42

    Unhappy Re: Mscomm not working in Windows7 64 bit

    thank you for the reply,
    But I found it difficult to understand the answer, Should I add under TRY.
    How will WinRs.exe help me.
    Yogi

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Mscomm not working in Windows7 64 bit

    MSComm should not be used in a VB.Net project.

    I would suggest using the Serial class included in the .Net framework instead.

    I would also suggest posting questions about .net in the VB.net section rather than the VB6 area.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2006
    Posts
    42

    Re: Mscomm not working in Windows7 64 bit

    THANKS for the prompt reply,
    I had already posted the question on vb.net forum, but after getting no response, I came here,
    cause MSCOMM is much the same for VB.net or VB.

    Main focus of my question irrespective of the technology was that how whether I can use MScomm in Windows 7 ,
    If it is possible in Vb i will convert my code from .net to Vb. ( if mscomm really works on Win 7)
    Yogi

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Mscomm not working in Windows7 64 bit

    I have not tried MSComm on windows 7 but if you are working with .net you would be best off to stay within the framework as much as possible.

    The serial class in .net works well and should not be a problem under windows 7 64 where as the older 32 bit MSComm may not be a wise choice.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Mscomm not working in Windows7 64 bit

    I've use this with Cellular Connections, as well as VPN connections. If you have a MODEM connection, it works.

    From a command prompt (elevated)

    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.
    WinRS /?

    USAGE
    =====
    (ALL UPPER-CASE = value that must be supplied by user.)

    winrs [-/SWITCH[:VALUE]] COMMAND

    COMMAND - Any string that can be executed as a command in the cmd.exe shell.

    SWITCHES
    ========
    (All switches accept both short form or long form. For example both -r and
    -remote are valid.)

    -r[emote]:ENDPOINT - The target endpoint using a NetBIOS name or the standa
    rd connection URL: [TRANSPORT://]TARGET[:PORT]. If not specified
    -r:localhost is used.

    -un[encrypted] - Specify that the messages to the remote shell will not
    be encrypted. This is useful for troubleshooting, or when the network traffic i
    s already encrypted using ipsec, or when physical security is enforced. By defau
    lt the messages are encrypted using Kerberos or NTLM keys. This switch is ignore
    d when HTTPS transport is selected.

    -u[sername]:USERNAME - Specify username on command line. If not specified the
    tool will use Negotiate authentication or prompt for the name.
    If -username is specified, -password must be as well.

    -p[assword]:PASSWORD - Specify password on command line. If -password is not
    specified but -username is the tool will prompt for the password. If -password i
    s specified, -user must be specified as well.

    -t[imeout]:SECONDS - This option is deprecated.

    -d[irectory]:PATH - Specifies starting directory for remote shell. If not
    specified the remote shell will start in the user's home directory defined by th
    e environment variable %USERPROFILE%.

    -env[ironment]:STRING=VALUE - Specifies a single environment variable to be se
    t when shell starts, which allows changing default environment for shell. Multip
    le occurrences of this switch must be used to specify multiple environment varia
    bles.

    -noe[cho] - Specifies that echo should be disabled. This may be ne
    cessary to ensure that user's answers to remote prompts are not displayed locall
    y. By default echo is "on".

    -nop[rofile] - Specifies that the user's profile should not be loaded
    . By default the server will attempt to load the user profile. If the remote use
    r is not a local administrator on the target system then this option will be req
    uired (the default will result in error).

    -a[llow]d[elegate] - Specifies that the user's credentials can be used to a
    ccess a remote share, for example, found on a different machine than the target
    endpoint.

    -comp[ression] - Turn on compression. Older installations on remote ma
    chines may not support compression so it is off by default.

    -[use]ssl - Use an SSL connection when using a remote endpoint. S
    pecifying this instead of the transport "https:" will use the default WinRM defa
    ult port.

    -? - Help

    To terminate the remote command the user can type Ctrl-C or Ctrl-Break, which wi
    ll be sent to the remote shell. The second Ctrl-C will force termination of winr
    s.exe.

    To manage active remote shells or WinRS configuration, use the WinRM tool. The
    URI alias to manage active shells is shell/cmd. The URI alias for WinRS configu
    ration is winrm/config/winrs. Example usage can be found in the WinRM tool by t
    yping "WinRM -?".

    Examples:
    winrs -r:https://myserver.com command
    winrs -r:myserver.com -usessl command
    winrs -r:myserver command
    winrs -r:http://127.0.0.1 command
    winrs -r:http://169.51.2.101:80 -unencrypted command
    winrs -r:https://[::FFFF:129.144.52.38] command
    winrs -r:http://[1080:0:0:0:8:800:200C:417A]:80 command
    winrs -r:https://myserver.com -t:600 -u:administrator -p:$%fgh7 ipconfig
    winrs -r:myserver -env:PATH=^%PATH^%;c:\tools -env:TEMP=d:\temp config.cmd
    winrs -r:myserver netdom join myserver /domain:testdomain /userd:johns /password
    d:$%fgh789
    winrs -r:myserver -ad -u:administrator -p:$%fgh7 dir \\anotherserver\share
    And, as it says:


    C:\Windows\system32>winrm /?
    Windows Remote Management Command Line Tool

    Windows Remote Management (WinRM) is the Microsoft implementation of
    the WS-Management protocol which provides a secure way to communicate
    with local and remote computers using web services.

    Usage:
    winrm OPERATION RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...]
    [@{KEY=VALUE[;KEY=VALUE]...}]

    For help on a specific operation:
    winrm g[et] -? Retrieving management information.
    winrm s[et] -? Modifying management information.
    winrm c[reate] -? Creating new instances of management resources.
    winrm d[elete] -? Remove an instance of a management resource.
    winrm e[numerate] -? List all instances of a management resource.
    winrm i[nvoke] -? Executes a method on a management resource.
    winrm id[entify] -? Determines if a WS-Management implementation is
    running on the remote machine.
    winrm quickconfig -? Configures this machine to accept WS-Management
    requests from other machines.
    winrm configSDDL -? Modify an existing security descriptor for a URI.
    winrm helpmsg -? Displays error message for the error code.

    For help on related topics:
    winrm help uris How to construct resource URIs.
    winrm help aliases Abbreviations for URIs.
    winrm help config Configuring WinRM client and service settings.
    winrm help certmapping Configuring client certificate access.
    winrm help remoting How to access remote machines.
    winrm help auth Providing credentials for remote access.
    winrm help input Providing input to create, set, and invoke.
    winrm help switches Other switches such as formatting, options, etc.
    winrm help proxy Providing proxy information.

    C:\Windows\system32>
    Last edited by dglienna; January 18th, 2011 at 11:20 AM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured