나를 놀 리고해야합니다! 이 질문을 게시 한 후 몇 초 만에 다른 방법으로 검색하기로 결정했는데 어떤 식 으로든 다음과 같은 내용이 나타났습니다. private static extern Microsoft.Win32 [DllImport ("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] .SafeHandles.SafeFileHandle CreateFile (문자열 lpFileName, System.UInt32 dwDesiredAccess, System.UInt32 dwShareMode, IntPtr pSecurityAttributes, System.UInt32 dwCreationDisposition, System.UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile); 모두 불만을 표합니다. 불편을 끼쳐 드려 죄송합니다.C# VB6 API 사용
저는 현재 가장 이상한 문제가 있습니다. 제가 잘 문서화되지 않은 것으로 밝혀졌습니다. C# .net을 통해 CreateFile, ReadFile 등과 같은 다양한 API를 사용하려고합니다. MessageBox API를 사용할 때 약간의 성공을 거두었지만 CreateFile과 동일한 작업을 시도 할 때 오류가 발생합니다. 아래에서 자세히 설명하겠습니다.
Step 1: Declarations a) MessageBox Declaration 1) VB6:`// Public Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long` 2) C#: `public static extern int MessageBox(int hwnd, string lptxt, string lcap, int wType);` Step 2: C# Usage: `MessageBox(0, "Text", "Caption", 0);
지금, 나는 지금의로 일하고 하지 인에서 CreateFile API에 관한 한 일을 보여줍니다.
단계 1 : 선언 a)를 CreateFile 선언 :
1) VB6:`// Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
2) C#: [DllImport("kernel32")]
public static extern long CreateFile(string lpFileName, long dwDesiredAccess, long dwShareMode, long lpSecurityAttributes, long dwCreationDisposition, long dwFlagsAndAttributes, long hTemplateFile);
단계 2 : C# 1 사용 : 긴 lFile; lFile = CreateFile (strIcoPath, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
내가 점점 오전 오류 : "PInvokeStackImbalance가 감지되었습니다 메시지 : PInvoke를 함수에 대한 호출 '! ScanTime Crypter을 공개 :: CreateFile이는'관리의 PInvoke 서명이 일치하지 않기 때문에 스택이 가능성이 높습니다 불균형이있다. 관리되지 않는 대상 서명. 호출 규칙 및 PInvoke 서명 매개 변수가 대상 관리되지 않는 서명과 일치하는지 확인하십시오. "
아마도 누군가는 내가하지 않는 것을 볼 것입니다. 모두에게 감사드립니다!
더 이상 관련이없는 질문은 삭제할 수 있습니다. – Aren
신의 사랑을 위해이 코드를 쓰지 마십시오. –
나는 이것을 배우기 위해서이기를 바랍니다. – Marlon