0

I'm trying to make a program with vb.net (VS2008) for studio shooting with my Nikon D600. I'm using a program called ControlMyNikon for tethered shooting and it's working perfectly. It has this external control-feature with following instructions: http://i.jjj.fi/a9dAQ7z.png

Could someone give me hint what does 'send string to 'ControlMyNikon v4.1' window with windows messages' actually mean?

I tried with SendMessages. I was able to change window title with WM_SETTEXT but that's all. I'm able to get the window handle but don't know how to send any string to it.

Help? :)

4

1 回答 1

1

呃,尼康因编写真正糟糕的铲子而臭名昭著。这并不令人失望。以下是一些应该起作用的声明。首先尝试 Unicode 版本。如果生成中文文本,则使用 Ansi 版本:

Imports System.Runtime.InteropServices

Class NativeMethods
    Friend Const WM_SETTEXT As Integer = 12

    <DllImport("user32.dll", EntryPoint:="SendMessageW", CharSet:=CharSet.Unicode)> _
    Friend Shared Function SetWindowTextUnicode(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
    End Function

    <DllImport("user32.dll", EntryPoint:="SendMessageA", CharSet:=CharSet.Ansi)> _
    Friend Shared Function SetWindowTextAnsi(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
    End Function
End Class

用法:

NativeMethods.SetWindowTextUnicode(handleYouFound, WM_SETTTEXT, IntPtr.Zero, "shoot")

如果两者都不起作用,那么您可能使用了错误的窗口句柄。使用 Spy++ 仔细检查您是否正确定位了窗口。

于 2013-04-14T12:18:02.043 回答