N
N
naming222020-04-27 11:38:51
C++ / C#
naming22, 2020-04-27 11:38:51

System.OverflowException: Arithmetic operation resulted in an overflow?

string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            String dName = "".PadRight(100);
            String dVersion = "".PadRight(100);
            IntPtr hWndC = capCreateCaptureWindowA("VFW Capture", WS_POPUP | WS_CHILD, 0, 0, 320, 240, 0, 0); // узнать дескриптор камеры
            SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0); //подключиться к камере
            string path = [email protected]"\ВАЖН0\text\" + "1" + ".jpg";
            IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
            SendMessage(hWndC, WM_CAP_SAVEDIB, 0, hBmp.ToInt32()); // сохранить скриншот
            SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); //отключить камеру

Unhandled exception. System.OverflowException: Arithmetic operation resulted in an overflow.
   at System.IntPtr.ToInt32()
   at cheatchecker.Program.Photo() in D:\code\c#-saves\cheatchecker\Program.cs:line 132
   at cheatchecker.Program.Main(String[] args) in D:\code\c#-saves\cheatchecker\Program.cs:line 44

Line 44 - function call.
How to fix it?) Or how to normally take a screenshot and save it as a file? Everything on google doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-stream, 2020-04-27
@naming22

And what is the connection between the camera and the screenshot?
the first search result: https://habr.com/ru/post/316012/

F
freeExec, 2020-04-27
@freeExec

hBmp.ToInt32()and in the x64 application, how will he convert the pointer to x32?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question