主頁 > .NET開發 > 使用winapi從設備讀取輸入時遇到問題

使用winapi從設備讀取輸入時遇到問題

2022-05-09 10:21:08 .NET開發

我按照此處的步驟嘗試從設備讀取一些輸入。我已經嘗試了幾個小時來弄清楚為什么GetMessage不回傳任何東西。最初我試圖從某個設備上讀取,但看到那不起作用,我只想嘗試讀取鍵盤或滑鼠輸入。但是,我沒有運氣這樣做。

編輯:更多資訊。我在 Windows 10 上。我在 cmder 中運行代碼(不確定這是否有任何區別)python main.py沒有錯誤訊息,輸出是Successfully registered input device!在程式等待從GetMessage.

這是運行代碼:

主要.py:

from ctypes import windll, sizeof, WinDLL, pointer, c_uint, create_string_buffer, POINTER
from ctypes.wintypes import *
from structures import *
from constants import *  # I put a comment specifying the value for each variable used from here


k32 = WinDLL('kernel32')
GetRawInputDeviceInfo = windll.user32.GetRawInputDeviceInfoA
GetRawInputDeviceInfo.argtypes = HANDLE, UINT, LPVOID, PUINT
RegisterRawInputDevices = windll.user32.RegisterRawInputDevices
RegisterRawInputDevices.argtypes = (RawInputDevice * 7), UINT, UINT
GetMessage = windll.user32.GetMessageA
GetMessage.argtypes = POINTER(Message), HWND, UINT, UINT


def print_error(code=None):
    print(f"Error code {k32.GetLastError() if code is None else code}")


def register_devices(hwnd_target=None):
    # Here I added all usages just to try and get any kind of response from GetMessage
    page = 0x01
    # DW_FLAGS is 0
    devices = (RawInputDevice * 7)(
        RawInputDevice(page, 0x01, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x02, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x04, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x05, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x06, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x07, DW_FLAGS, hwnd_target),
        RawInputDevice(page, 0x08, DW_FLAGS, hwnd_target),
    )
    if not RegisterRawInputDevices(devices, len(devices), sizeof(devices[0])):
        print_error()
    else:
        print("Successfully registered input device!")


def get_message(h_wnd=None):
    msg = pointer(Message())
    # WM_INPUT is 0
    return_value = GetMessage(msg, h_wnd, WM_INPUT, WM_INPUT)
    if return_value == -1:
        print_error()
    elif return_value == 0:
        print("WM_QUIT message received.")
    else:
        print("Successfully got message!")
        return msg


register_devices()
print(get_message().contents.message)

結構.py:

from ctypes import Structure
from ctypes.wintypes import *


class RawInputDevice(Structure):
    _fields_ = [
        ("usUsagePage", USHORT),
        ("usUsage", USHORT),
        ("dwFlags", DWORD),
        ("hwndTarget", HWND),
    ]


class Message(Structure):
    _fields_ = [
        ("hwnd", HWND),
        ("message", UINT),
        ("wParam", WPARAM),
        ("lParam", LPARAM),
        ("time", DWORD),
        ("pt", POINT),
        ("lPrivate", DWORD)
    ]

如果有人幫助我找出問題所在,我將不勝感激,或者如果有人能指出從 Windows 上的 HID 設備讀取輸入的替代方法,我也會很好。

uj5u.com熱心網友回復:

我將從(主要)資源開始:

  • [MS.Docs]:使用原始輸入

  • [SO]:簡單 main() 中的 getrawinputdata

  • [SO]:是否可以在沒有視窗的情況下使用 Windows Raw Input API(即來自控制臺應用程式)?

  • [CodeProject]:使用 RAWINPUT 的最小鍵盤記錄器

  • [Python.Docs]: ctypes - Python 的外來函式庫

  • [GitHub]:mhammond/pywin32 - pywin32

我準備了一個例子。

ctypes_wrappers.py


import ctypes as ct
import ctypes.wintypes as wt


HCURSOR = ct.c_void_p
LRESULT = ct.c_ssize_t

wndproc_args = (wt.HWND, wt.UINT, wt.WPARAM, wt.LPARAM)

WNDPROC = ct.CFUNCTYPE(LRESULT, *wndproc_args)

kernel32 = ct.WinDLL("Kernel32")
user32 = ct.WinDLL("User32")


def structure_to_string_method(self):
    ret = [f"{self.__class__.__name__} (size: {ct.sizeof(self.__class__)}) instance at 0x{id(self):016X}:"]
    for fn, _ in self._fields_:
        ret.append(f"  {fn}: {getattr(self, fn)}")
    return "\n".join(ret)   "\n"

union_to_string_method = structure_to_string_method


class Struct(ct.Structure):
    to_string = structure_to_string_method


class Uni(ct.Union):
    to_string = union_to_string_method


class WNDCLASSEXW(Struct):
    _fields_ = (
        ("cbSize", wt.UINT),
        ("style", wt.UINT),
        #("lpfnWndProc", ct.c_void_p),
        ("lpfnWndProc", WNDPROC),
        ("cbClsExtra", ct.c_int),
        ("cbWndExtra", ct.c_int),
        ("hInstance", wt.HINSTANCE),
        ("hIcon", wt.HICON),
        ("hCursor", HCURSOR),
        ("hbrBackground", wt.HBRUSH),
        ("lpszMenuName", wt.LPCWSTR),
        ("lpszClassName", wt.LPCWSTR),
        ("hIconSm", wt.HICON),
    )

WNDCLASSEX = WNDCLASSEXW


class RawInputDevice(Struct):
    _fields_ = (
        ("usUsagePage", wt.USHORT),
        ("usUsage", wt.USHORT),
        ("dwFlags", wt.DWORD),
        ("hwndTarget", wt.HWND),
    )

PRawInputDevice = ct.POINTER(RawInputDevice)


class RAWINPUTHEADER(Struct):
    _fields_ = (
        ("dwType", wt.DWORD),
        ("dwSize", wt.DWORD),
        ("hDevice", wt.HANDLE),
        ("wParam", wt.WPARAM),
    )


class RAWMOUSE(Struct):
    _fields_ = (
        ("usFlags", wt.USHORT),
        ("ulButtons", wt.ULONG),  # unnamed union: 2 USHORTS: flags, data
        ("ulRawButtons", wt.ULONG),
        ("lLastX", wt.LONG),
        ("lLastY", wt.LONG),
        ("ulExtraInformation", wt.ULONG),
    )


class RAWKEYBOARD(Struct):
    _fields_ = (
        ("MakeCode", wt.USHORT),
        ("Flags", wt.USHORT),
        ("Reserved", wt.USHORT),
        ("VKey", wt.USHORT),
        ("Message", wt.UINT),
        ("ExtraInformation", wt.ULONG),
    )


class RAWHID(Struct):
    _fields_ = (
        ("dwSizeHid", wt.DWORD),
        ("dwCount", wt.DWORD),
        ("bRawData", wt.BYTE * 1),  # @TODO - cfati: https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rawhid, but not very usable via CTypes
    )


class RAWINPUT_U0(Uni):
    _fields_ = (
        ("mouse", RAWMOUSE),
        ("keyboard", RAWKEYBOARD),
        ("hid", RAWHID),
    )


class RAWINPUT(Struct):
    _fields_ = (
        ("header", RAWINPUTHEADER),
        ("data", RAWINPUT_U0),
    )

PRAWINPUT = ct.POINTER(RAWINPUT)


GetLastError = kernel32.GetLastError
GetLastError.argtypes = ()
GetLastError.restype = wt.DWORD

GetModuleHandle = kernel32.GetModuleHandleW
GetModuleHandle.argtypes = (wt.LPWSTR,)
GetModuleHandle.restype = wt.HMODULE


DefWindowProc = user32.DefWindowProcW
DefWindowProc.argtypes = wndproc_args
DefWindowProc.restype = LRESULT

RegisterClassEx = user32.RegisterClassExW
RegisterClassEx.argtypes = (ct.POINTER(WNDCLASSEX),)
RegisterClassEx.restype = wt.ATOM

CreateWindowEx = user32.CreateWindowExW
CreateWindowEx.argtypes = (wt.DWORD, wt.LPCWSTR, wt.LPCWSTR, wt.DWORD, ct.c_int, ct.c_int, ct.c_int, ct.c_int, wt.HWND, wt.HMENU, wt.HINSTANCE, wt.LPVOID)
CreateWindowEx.restype = wt.HWND

RegisterRawInputDevices = user32.RegisterRawInputDevices
RegisterRawInputDevices.argtypes = (PRawInputDevice, wt.UINT, wt.UINT)
RegisterRawInputDevices.restype = wt.BOOL

GetRawInputData = user32.GetRawInputData
GetRawInputData.argtypes = (PRAWINPUT, wt.UINT, wt.LPVOID, wt.PUINT, wt.UINT)
GetRawInputData.restype = wt.UINT

GetMessage = user32.GetMessageW
GetMessage.argtypes = (wt.LPMSG, wt.HWND, wt.UINT, wt.UINT)
GetMessage.restype = wt.BOOL

PeekMessage = user32.PeekMessageW
PeekMessage.argtypes = (wt.LPMSG, wt.HWND, wt.UINT, wt.UINT, wt.UINT)
PeekMessage.restype = wt.BOOL

TranslateMessage = user32.TranslateMessage
TranslateMessage.argtypes = (wt.LPMSG,)
TranslateMessage.restype = wt.BOOL

DispatchMessage = user32.DispatchMessageW
DispatchMessage.argtypes = (wt.LPMSG,)
DispatchMessage.restype = LRESULT

PostQuitMessage = user32.PostQuitMessage
PostQuitMessage.argtypes = (ct.c_int,)
PostQuitMessage.restype = None

代碼00.py

#!/usr/bin/env python

import ctypes as ct
import ctypes.wintypes as wt
import sys
import time

import ctypes_wrappers as cw


HWND_MESSAGE = -3

WM_QUIT = 0x0012
WM_INPUT = 0x00FF
WM_KEYUP = 0x0101
WM_CHAR = 0x0102

HID_USAGE_PAGE_GENERIC = 0x01

RIDEV_NOLEGACY = 0x00000030
RIDEV_INPUTSINK = 0x00000100
RIDEV_CAPTUREMOUSE = 0x00000200

RID_HEADER = 0x10000005
RID_INPUT = 0x10000003

RIM_TYPEMOUSE = 0
RIM_TYPEKEYBOARD = 1
RIM_TYPEHID = 2

PM_NOREMOVE = 0x0000


def wnd_proc(hwnd, msg, wparam, lparam):
    print(f"Handle message - hwnd: 0x{hwnd:016X} msg: 0x{msg:08X} wp: 0x{wparam:016X} lp: 0x{lparam:016X}")
    if msg == WM_INPUT:
        size = wt.UINT(0)
        res = cw.GetRawInputData(ct.cast(lparam, cw.PRAWINPUT), RID_INPUT, None, ct.byref(size), ct.sizeof(cw.RAWINPUTHEADER))
        if res == wt.UINT(-1) or size == 0:
            print_error(text="GetRawInputData 0")
            return 0
        buf = ct.create_string_buffer(size.value)
        res = cw.GetRawInputData(ct.cast(lparam, cw.PRAWINPUT), RID_INPUT, buf, ct.byref(size), ct.sizeof(cw.RAWINPUTHEADER))
        if res != size.value:
            print_error(text="GetRawInputData 1")
            return 0
        #print("kkt: ", ct.cast(lparam, cw.PRAWINPUT).contents.to_string())
        ri = ct.cast(buf, cw.PRAWINPUT).contents
        #print(ri.to_string())
        head = ri.header
        print(head.to_string())
        #print(ri.data.mouse.to_string())
        #print(ri.data.keyboard.to_string())
        #print(ri.data.hid.to_string())
        if head.dwType == RIM_TYPEMOUSE:
            data = ri.data.mouse
        elif head.dwType == RIM_TYPEKEYBOARD:
            data = ri.data.keyboard
            if data.VKey == 0x1B:
                cw.PostQuitMessage(0)
        elif head.dwType == RIM_TYPEHID:
            data = ri.data.hid
        else:
            print("Wrong raw input type!!!")
            return 0
        print(data.to_string())
    return cw.DefWindowProc(hwnd, msg, wparam, lparam)


def print_error(code=None, text=None):
    text = text   " - e" if text else "E"
    code = cw.GetLastError() if code is None else code
    print(f"{text}rror code: {code}")


def register_devices(hwnd=None):
    flags = RIDEV_INPUTSINK  # @TODO - cfati: If setting to 0, GetMessage hangs
    generic_usage_ids = (0x01, 0x02, 0x04, 0x05, 0x06, 0x07, 0x08)
    devices = (cw.RawInputDevice * len(generic_usage_ids))(
        *(cw.RawInputDevice(HID_USAGE_PAGE_GENERIC, uid, flags, hwnd) for uid in generic_usage_ids)
    )
    #for d in devices: print(d.usUsagePage, d.usUsage, d.dwFlags, d.hwndTarget)
    if cw.RegisterRawInputDevices(devices, len(generic_usage_ids), ct.sizeof(cw.RawInputDevice)):
        print("Successfully registered input device(s)!")
        return True
    else:
        print_error(text="RegisterRawInputDevices")
        return False


def main(*argv):
    wnd_cls = "SO049572093_RawInputWndClass"
    wcx = cw.WNDCLASSEX()
    wcx.cbSize = ct.sizeof(cw.WNDCLASSEX)
    #wcx.lpfnWndProc = ct.cast(cw.DefWindowProc, ct.c_void_p)
    wcx.lpfnWndProc = cw.WNDPROC(wnd_proc)
    wcx.hInstance = cw.GetModuleHandle(None)
    wcx.lpszClassName = wnd_cls
    #print(dir(wcx))
    res = cw.RegisterClassEx(ct.byref(wcx))
    if not res:
        print_error(text="RegisterClass")
        return 0
    hwnd = cw.CreateWindowEx(0, wnd_cls, None, 0, 0, 0, 0, 0, 0, None, wcx.hInstance, None)
    if not hwnd:
        print_error(text="CreateWindowEx")
        return 0
    #print("hwnd:", hwnd)
    if not register_devices(hwnd):
        return 0
    msg = wt.MSG()
    pmsg = ct.byref(msg)
    print("Start loop (press <ESC> to exit)...")
    while res := cw.GetMessage(pmsg, None, 0, 0):
        if res < 0:
            print_error(text="GetMessage")
            break
        cw.TranslateMessage(pmsg)
        cw.DispatchMessage(pmsg)


if __name__ == "__main__":
    print("Python {:s} {:03d}bit on {:s}\n".format(" ".join(elem.strip() for elem in sys.version.split("\n")),
                                                   64 if sys.maxsize > 0x100000000 else 32, sys.platform))
    rc = main(*sys.argv[1:])
    print("\nDone.")
    sys.exit(rc)

輸出

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q071994439]> "e:\Work\Dev\VEnvs\py_pc064_03.09_test0\Scripts\python.exe" code00.py
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] 064bit on win32

Handle message - hwnd: 0x00000000002F0606 msg: 0x00000024 wp: 0x0000000000000000 lp: 0x000000F5E0BEDDE0
Handle message - hwnd: 0x00000000002F0606 msg: 0x00000081 wp: 0x0000000000000000 lp: 0x000000F5E0BEDD70
Handle message - hwnd: 0x00000000002F0606 msg: 0x00000083 wp: 0x0000000000000000 lp: 0x000000F5E0BEDE00
Handle message - hwnd: 0x00000000002F0606 msg: 0x00000001 wp: 0x0000000000000000 lp: 0x000000F5E0BEDD70
Successfully registered input device(s)!
Start loop (press <ESC> to exit)...
Handle message - hwnd: 0x00000000002F0606 msg: 0x0000031F wp: 0x0000000000000001 lp: 0x0000000000000000
Handle message - hwnd: 0x00000000002F0606 msg: 0x000000FF wp: 0x0000000000000001 lp: 0x-00000003849FCDF
RAWINPUTHEADER (size: 24) instance at 0x00000296313BBBC0:
  dwType: 1
  dwSize: 40
  hDevice: 843780541
  wParam: 1

RAWKEYBOARD (size: 16) instance at 0x00000296313BBCC0:
  MakeCode: 30
  Flags: 0
  Reserved: 0
  VKey: 65
  Message: 256
  ExtraInformation: 0

Handle message - hwnd: 0x00000000002F0606 msg: 0x000000FF wp: 0x0000000000000001 lp: 0x0000000031AE1619
RAWINPUTHEADER (size: 24) instance at 0x00000296313BBBC0:
  dwType: 1
  dwSize: 40
  hDevice: 843780541
  wParam: 1

RAWKEYBOARD (size: 16) instance at 0x00000296313BBD40:
  MakeCode: 30
  Flags: 1
  Reserved: 0
  VKey: 65
  Message: 257
  ExtraInformation: 0

Handle message - hwnd: 0x00000000002F0606 msg: 0x000000FF wp: 0x0000000000000001 lp: 0x000000007C851501
RAWINPUTHEADER (size: 24) instance at 0x00000296313BBBC0:
  dwType: 0
  dwSize: 48
  hDevice: 4461491
  wParam: 1

RAWMOUSE (size: 24) instance at 0x00000296313BBDC0:
  usFlags: 0
  ulButtons: 1
  ulRawButtons: 0
  lLastX: 0
  lLastY: 0
  ulExtraInformation: 0

Handle message - hwnd: 0x00000000002F0606 msg: 0x000000FF wp: 0x0000000000000001 lp: 0x0000000031B41619
RAWINPUTHEADER (size: 24) instance at 0x00000296313BBBC0:
  dwType: 0
  dwSize: 48
  hDevice: 4461491
  wParam: 1

RAWMOUSE (size: 24) instance at 0x00000296313BBE40:
  usFlags: 0
  ulButtons: 2
  ulRawButtons: 0
  lLastX: 0
  lLastY: 0
  ulExtraInformation: 0

Handle message - hwnd: 0x00000000002F0606 msg: 0x000000FF wp: 0x0000000000000001 lp: 0x0000000052D10665
RAWINPUTHEADER (size: 24) instance at 0x00000296313BBBC0:
  dwType: 1
  dwSize: 40
  hDevice: 843780541
  wParam: 1

RAWKEYBOARD (size: 16) instance at 0x00000296313BBEC0:
  MakeCode: 1
  Flags: 0
  Reserved: 0
  VKey: 27
  Message: 256
  ExtraInformation: 0


Done.

備注

  • (以上)輸出由以下操作生成:aLClickESC

  • 我放棄了PyWin32,因為它不包含我們需要的函式(不屬于Raw Input系列),但它可能(至少)用于win32con中的常量(以避免定義它們)

  • 我認為可以通過將功能從wnd_proc移動到mainwhile回圈來簡化事情(因此可以洗掉所有視窗類的東西(常量、結構、函式)),但我是這樣開始的,我不喜歡改變它

  • 一個重大突破是RIDEV_INPUTSINK(從那時起,GetMessage停止掛起)

  • RAWHID結構(@TODO)被“按書”包裝,但它不會在OOTB中作業(你提到過使用其他型別的設備)。最后的(1 大小)陣列只是說明將跟隨一些附加資料(dwSizeHid大小)的一種方式,這些資料顯然不適合一個位元組。那里需要一個“技巧”:必須根據資料的大小動態定義結構(例如:[SO]:在 ctypes.Structure 中動態設定_fields_(@CristiFati 的答案) -我記得我寫了一個更新的答案關于那個主題,但我找不到或不記得它),以及所有這些行為(遞回)在封裝它的所有結構(聯合)中傳播

uj5u.com熱心網友回復:

GetMessage 用于訊息泵,請參閱https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage我不知道你應該使用什么,但 GetMessage 絕對不適合這種用途。

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/470862.html

標籤:Python 温纳皮 类型

上一篇:如何監控內核回呼

下一篇:如何更改視窗滾動條的位置?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more