Search Results

Search found 746 results on 30 pages for 'winapi'.

Page 18/30 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • What is XcvPort (used in OpenPrinter function)

    - by RiskX
    I'm usin the OpenPrinter function and the first parameter the function gets called "pPrinterName" and that's it's MSDN description: [in] Pointer to a null-terminated string that specifies the name of the printer or print server, the printer object, the XcvMonitor, or the XcvPort. For a printer object use: PrinterName,Job xxxx. For an XcvMonitor, use: ServerName,XcvMonitor MonitorName. For an XcvPort, use: ServerName,XcvPort PortName. Obviously I'm interested in the bold part. What exactly is XcvPort? I know it seems like a question of lazy person but I really couldn't find info abou this concept. If I would like to open a printer on port ABC I should write: "\\MySrever,XcvPort ABC"? Thank you for your answers!

    Read the article

  • Detect a USB drive being inserted - Windows Service

    - by Tom Bell
    I am trying to detect a USB disk drive being inserted within a Windows Service, I have done this as a normal Windows application. The problem is the following code doesn't work for volumes. Registering the device notification: DEV_BROADCAST_DEVICEINTERFACE notificationFilter; HDEVNOTIFY hDeviceNotify = NULL; ::ZeroMemory(&notificationFilter, sizeof(notificationFilter)); notificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); notificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; notificationFilter.dbcc_classguid = ::GUID_DEVINTERFACE_VOLUME; hDeviceNotify = ::RegisterDeviceNotification(g_serviceStatusHandle, &notificationFilter, DEVICE_NOTIFY_SERVICE_HANDLE); The code from the ServiceControlHandlerEx function: case SERVICE_CONTROL_DEVICEEVENT: PDEV_BROADCAST_HDR pBroadcastHdr = (PDEV_BROADCAST_HDR)lpEventData; switch (dwEventType) { case DBT_DEVICEARRIVAL: ::MessageBox(NULL, "A Device has been plugged in.", "Pounce", MB_OK | MB_ICONINFORMATION); switch (pBroadcastHdr->dbch_devicetype) { case DBT_DEVTYP_DEVICEINTERFACE: PDEV_BROADCAST_DEVICEINTERFACE pDevInt = (PDEV_BROADCAST_DEVICEINTERFACE)pBroadcastHdr; if (::IsEqualGUID(pDevInt->dbcc_classguid, GUID_DEVINTERFACE_VOLUME)) { PDEV_BROADCAST_VOLUME pVol = (PDEV_BROADCAST_VOLUME)pDevInt; char szMsg[80]; char cDriveLetter = ::GetDriveLetter(pVol->dbcv_unitmask); ::wsprintfA(szMsg, "USB disk drive with the drive letter '%c:' has been inserted.", cDriveLetter); ::MessageBoxA(NULL, szMsg, "Pounce", MB_OK | MB_ICONINFORMATION); } } return NO_ERROR; } In a Windows application I am able to get the DBT_DEVTYP_VOLUME in dbch_devicetype, however this isn't present in a Windows Service implementation. Has anyone seen or heard of a solution to this problem, without the obvious, rewrite as a Windows application?

    Read the article

  • How can I disable mouse click event system wide using C#?

    - by mazzzzz
    Hey guys, I have a laptop with a very sensitive touch pad, and wanted to code a small program that could block the mouse input when I was typing a paper or something. I didn't think it would be hard to do, considering everything I've seen on low-level hooks, but I was wrong (astounding, right?). I looked at a few examples, but the examples I've seen either block both keyboard and mouse, or just hide the mouse. Any help with this would be great.

    Read the article

  • Why does GetTextFace always return "system"?

    - by user545142
    I am trying to get the font of controls in other applications. When I try WM_GETFONT, it returns 0. This my code: [DllImport("User32.DLL")] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); IntPtr fx = SendMessage(button1.Handle, 0x31, 0, 0); When I use GetTextFace with a button, it always returns "system". This is my code: StringBuilder Buff = new StringBuilder(256); IntPtr dc = GetDCEx(button1.Handle, IntPtr.Zero, DeviceContextValues.Window |DeviceContextValues.Cache | DeviceContextValues.ClipSiblings | DeviceContextValues.IntersectRgn); IntPtr hfont = GetTextFace(dc, 256, Buff); Of course I'm sure I changed the font type. How can I solve this problem? I am using C# under Windows 7.

    Read the article

  • Low Level Console Input

    - by Soulseekah
    I'm trying to send commands to to the input of a cmd.exe application using the low level read/write console functions. I have no trouble reading the text (scraping) using the ReadConsole...() and WriteConsole() functions after having attached to the process console, but I've not figured out how to write for example "dir" and have the console interpret it as a sent command. Here's a bit of my code: CreateProcess(NULL, "cmd.exe", NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); AttachConsole(pi.dwProcessId); strcpy(buffer, "dir"); WriteConsole(GetStdHandle(STD_INPUT_HANDLE), buffer, strlen(buffer), &charRead, NULL); STARTUPINFO attributes of the process are all set to zero, except, of course, the .cb attribute. Nothing changes on the screen, however I'm getting an Error 6: Invalid Handle returned from WriteConsole to STD_INPUT_HANDLE. If I write to (STD_OUTPUT_HANDLE) I do get my dir written on the screen, but nothing of course happens. I'm guessing SetConsoleMode() might be of help, but I've tried many mode combinations, nothing helped. I've also created a quick console application that waits for input (scanf()) and echoes back whatever goes in, didn't work. I've also tried typing into the scanf() promp and then peek into the input buffer using PeekConsoleInput(), returns 0, but the INPUT_RECORD array is empty. I'm aware that there is another way around this using WriteConsoleInput() to directly inject INPUT_RECORD structured events into the console, but this would be way too long, I'll have to send each keypress into it. I hope the question is clear. Please let me know if you need any further information. Thanks for your help.

    Read the article

  • How to programmatically cut/copy/get files to/from Windows clipboard in a systam standard compliand

    - by Ivan
    How to put a cut/copy reference to specific files and/or folders into Windows clipboard so that when I open standard Windows Explorer window, go to somewhere and press Ctrl+V - the files are pasted? If I copy or cut some files/folders in Windows Explorer, how do I get this info (full names and whether they were cut or copied) in my Program? I program in C#4, but other languages ways are also interesting to know.

    Read the article

  • Change default Console I/O functions handle.

    - by b-gen-jack-o-neill
    Hello. Is it possible to somehow change standart I/O functions handle on Windows? Language preffered is C++. If I understand it right, by selecting console project, compiler just pre-allocate console for you, and operates all standart I/O functions to work with its handle. So, what I want to do is to let one Console app actually write into another app Console buffer. I though that I could get first´s Console handle, than pass it to second app by a file (I don´t know much about interprocess comunication, and this seems easy) and than somehow use for example prinf with the first app handle. Can this be done? I know how to get console handle, but I have no idea how to redirect printf to that handle. Its just study-purpose project to more understand of OS work behind this. I am interested in how printf knows what Console it is assiciated with.

    Read the article

  • In threads, WaitForMultipleObjects never returns if set to INFINITE

    - by AKN
    Let say I have three thread handles HandleList[0] = hThread1; HandleList[1] = hThread2; HandleList[2] = hThread3; /*All the above are of type HANDLE*/ Before closing the application, I want the thread to get its task done. So I want to make app wait till thread completes. So I do, WaitForMultipleObjects(3, HandleList, TRUE, INFINITE ); By this I'm able to make the thread, complete its task. But control never move to next line after the call to WaitForMultileObjects irrespective of all thread completing its task. If I use, some seconds instead of INFINITE, it comes to next line after that many secs, irrspective of whether thread completes its task or not. WaitForMultipleObjects(3, HandleList, TRUE, 10000 ); My problem here is, I'm can't go for seconds, as I may not be sure whether the threads will complete its task with the given time. To list my problem in simple words, I want all my thread to finish the task, before I close my app. How can I achieve it using WaitForMultipleObjects API?

    Read the article

  • Objective C for Windows

    - by Luther Baker
    What would be the best way to write Objective-C on the Windows platform? Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio? Along those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a different beast but I know I can write assembly and link in the Windows DLLs giving me accessibility to those calls but I don't know how to do this without googling and getting piecemeal directions. Is anyone aware of a good online or book resource to do or explain these kinds of things?

    Read the article

  • Help Using NetuserAdd() and NetLocalGroupAddMembers() in C++

    - by Brett Powell
    So I think I almost got it. I create my dummy account with one function, and wrote a second function to add it to the Remote Desktop group. Problem is, the Administrator account is the one logged in, so I am not sure how to specify what account to add to the group. Here is my code... The user is being created properly... void AddRDPUser() { USER_INFO_1 ui; DWORD dwLevel = 1; DWORD dwError = 0; NET_API_STATUS nStatus; ui.usri1_name = L"BrettXFactor"; ui.usri1_password = L"XfactorsServer96"; ui.usri1_priv = USER_PRIV_USER; ui.usri1_home_dir = NULL; ui.usri1_comment = NULL; ui.usri1_flags = UF_SCRIPT; ui.usri1_script_path = NULL; nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&ui, &dwError); } But I dont know how to specify to add them to this group since they are not logged in. Any help would be appreciated void AddToGroup() { LOCALGROUP_MEMBERS_INFO_3 lgmi3; DWORD dwLevel = 3; DWORD totalEntries = 1; NET_API_STATUS nStatus; LPCWSTR TargetGroup = L"Remote Desktop Users"; LPSTR sBuffer = NULL; memset(sBuffer, 0, 255); DWORD nBuffSize = sizeof(sBuffer); if(GetUserNameEx(NameDnsDomain, sBuffer, &nBuffSize)==0) { Msg("Failed to add User to Group\n"); return; } LPWSTR user_name = (LPWSTR)sBuffer; lgmi3.lgrmi3_domainandname = user_name; nStatus = NetLocalGroupAddMembers(NULL, TargetGroup, 3, (LPBYTE)&lgmi3, totalEntries); }

    Read the article

  • Creating additional Window by a thread - C

    - by Jamie Keeling
    Hello, I have a windows form that has a simple menu and performs a simple operation, I want to be able to create another windows form with all the functionality of a menu bar, message pump etc.. as a separate thread so I can then share the results of the operation to the second window. I.E. 1) Form A opens Form B opens as a separate thread 2)Form A performs operation 3)Form A passes results via memory to Form B 4)Form B display results I'm confused as to how to go about it, the main app runs fine but i'm not sure how to add a second window if the first one already exists. I hope it makes sense. Thanks!

    Read the article

  • Closing a window when it's "no longer needed".

    - by Mason Blier
    This is kind of a hard question to describe, and I've searched for about an hour now to no avail. Essentially, picture a small 'flyout' window like the Windows 7 Wireless Control or the Volume Slider from the system tray(notification area). When you click on the icon, the application pops up with focus, and if you click off of it, the window destroys itself. I thought it woudl be easily solved by simply having my window destroy it self when it loses focus (I've been listening for WM_KILLFOCUS), but the problem is, if the icon is clicked, my window does not always get focus. Since this isn't the case, if the user clicks my icon, and then clicks away because it was a mistake (on the desktop say), then how can I set my app to close? I've tried messing with SPY++ but checking the volume control / wireless control apps are proving difficult as they disappear when I try to get their window/process handles. Thanks!

    Read the article

  • Creating two Windows by running one as a process from another - C

    - by Jamie Keeling
    Hello, I have a windows form that has a simple menu and performs a simple operation, I want to be able to create another windows form with all the functionality of a menu bar, message pump etc.. as a seperate process so I can then share the results of the operation to the second window. I.E. 1) Form A opens Form B opens as a separate process 2)Form A performs operation 3)Form A passes results via memory to Form B 4)Form B display results I'm confused as to how to go about it, the main app runs fine but i'm not sure how to add a second window if the first one already exists. I hope it makes sense. Thanks!

    Read the article

  • Creating a Modeless Dialog

    - by Tom
    I'm trying to create a child modeless dialog of a dialog and currently I'm using these style parameters: STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW I'm not being able to transfer the control its parent dialog once i try to create its child dialog. is there anything else I'm missing in the process to make the dialog modeless?

    Read the article

  • Why does DestroyWindow close my application?

    - by user146780
    I'v created a window after creating my main one but calling DestroyWindow on its handle closes the entire application, how can I simply get rid of it? it looks like this: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; HWND fakehandle; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_EX_LAYERED, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); fakehandle = CreateWindow(szWindowClass, "FAKE WINDOW", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd || !fakehandle) { return FALSE; } //some code DestroyWindow(fakehandle); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } how can I destroy this window without destroying my main one? I'm creating a dummy window to check for multisampling in OpenGL. Thanks

    Read the article

  • Can somebody explain this remark in the MSDN CreateMutex() documentation about the bInitialOwner fla

    - by Tom Williams
    The MSDN CreatMutex() documentation (http://msdn.microsoft.com/en-us/library/ms682411%28VS.85%29.aspx) contains the following remark near the end: Two or more processes can call CreateMutex to create the same named mutex. The first process actually creates the mutex, and subsequent processes with sufficient access rights simply open a handle to the existing mutex. This enables multiple processes to get handles of the same mutex, while relieving the user of the responsibility of ensuring that the creating process is started first. When using this technique, you should set the bInitialOwner flag to FALSE; otherwise, it can be difficult to be certain which process has initial ownership. Can somebody explain the problem with using bInitialOwner = TRUE? Earlier in the same documentation it suggests a call to GetLastError() will allow you to determine whether a call to CreateMutext() created the mutex or just returned a new handle to an existing mutex: Return Value If the function succeeds, the return value is a handle to the newly created mutex object. If the function fails, the return value is NULL. To get extended error information, call GetLastError. If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object, GetLastError returns ERROR_ALREADY_EXISTS, bInitialOwner is ignored, and the calling thread is not granted ownership. However, if the caller has limited access rights, the function will fail with ERROR_ACCESS_DENIED and the caller should use the OpenMutex function.

    Read the article

  • How to properly recreate BITMAP, that was previously shared by CreateFileMapping()?

    - by zim22
    Dear friends, I need your help. I need to send .bmp file to another process (dialog box) and display it there, using MMF(Memory Mapped File) But the problem is that image displays in reversed colors and upside down. In first application I open picture from HDD and link it to the named MMF "Gigabyte_picture" HANDLE hFile = CreateFile("123.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, "Gigabyte_picture"); In second application I open mapped bmp file and at the end I display m_HBitmap on the static component, using SendMessage function. HANDLE hMappedFile = OpenFileMapping(FILE_MAP_READ, FALSE, "Gigabyte_picture"); PBYTE pbData = (PBYTE) MapViewOfFile(hMappedFile, FILE_MAP_READ, 0, 0, 0); BITMAPINFO bmpInfo = { 0 }; LONG lBmpSize = 60608; // size of the bmp file in bytes bmpInfo.bmiHeader.biBitCount = 32; bmpInfo.bmiHeader.biHeight = 174; bmpInfo.bmiHeader.biWidth = 87; bmpInfo.bmiHeader.biPlanes = 1; bmpInfo.bmiHeader.biSizeImage = lBmpSize; bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); UINT * pPixels = 0; HDC hDC = CreateCompatibleDC(NULL); HBITMAP m_HBitmap = CreateDIBSection(hDC, &bmpInfo, DIB_RGB_COLORS, (void **)& pPixels, NULL, 0); SetBitmapBits(m_HBitmap, lBmpSize, pbData); SendMessage(gStaticBox, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)m_HBitmap); ///////////// HWND gStaticBox = CreateWindowEx(0, "STATIC","", SS_CENTERIMAGE | SS_REALSIZEIMAGE | SS_BITMAP | WS_CHILD | WS_VISIBLE, 10,10,380, 380, myDialog, (HMENU)-1,NULL,NULL);

    Read the article

  • Running processes at different times stops events from working - C

    - by Jamie Keeling
    Hello, This is a question which follows on from my previously answered question here At first I assumed I had a problem with the way I was creating my events due to the handles for OpenEvent returning NULL, I have managed to find the real cause however I am not sure how to go about it. Basically I use Visual Studio to launch both Process A and B at the same time, in the past my OpenEvent handle wouldn't work due to Process A looking for the address of the event a fraction of a second before Process B had time to make it. My solution was to simply allow Process B to run before Process A, fixing the error. The problem I have now is that Process B now reads events from Process A and as you expect it too returns a null handle when trying to open the events from Process A. I am creating the events in WM_CREATE message of both processes, furthermore I also create a thread at the same time to open/read/act upon the events. It seems if I run them at the same time they don't get chance to see each other, alternatively if I run one before the other one of them misses out and can't open a Handle. Can anyone suggest a solution? Thanks.

    Read the article

  • CreateProcess() fails with an access violation

    - by John Doe
    My aim is to execute an external executable in my program. First, I used system() function, but I don't want the console to be seen to the user. So, I searched a bit, and found CreateProcess() function. However, when I try to pass a parameter to it, I don't know why, it fails. I took this code from MSDN, and changed a bit: #include <windows.h> #include <stdio.h> #include <tchar.h> void _tmain( int argc, TCHAR *argv[] ) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); /* if( argc != 2 ) { printf("Usage: %s [cmdline]\n", argv[0]); return; } */ // Start the child process. if( !CreateProcess( NULL, // No module name (use command line) L"c:\\users\\e\\desktop\\mspaint.exe", // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi ) // Pointer to PROCESS_INFORMATION structure ) { printf( "CreateProcess failed (%d).\n", GetLastError() ); return; } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } However, this code crated access violation somehow. Can I execute mspaint without showing user the console? Thank you very much.

    Read the article

  • How do I play flash files in pure C?

    - by CDR
    As part of a customized media player written in C (Win32), I need to enable my app play flash movies (.swf files) inside the player window. Can someone please indicate the most C compatible low level way to achieve this, giving me highest control? Specially control on display window and network access. I am looking for reference to a Windows DLL like flash_player.dll (if there is such thing) with documentation. Or at least a COM/ActiveX controls. Note that ActiveX is harder to use in C, than in say VB.

    Read the article

  • Windows API Programing....

    - by vs4vijay
    Hello There... Its me Vijay.. I m Trying to make a CrossHair(some kind of cursor) On The Screen while running a Game (Counter Strike)... so i did this... ############################# #include<iostream.h> #include<windows.h> #include<conio.h> #include<dos.h> #include<stdlib.h> #include<process.h> #include <time.h> int main() { HANDLE hl = OpenProcess(PROCESS_ALL_ACCESS,TRUE,pid); // Here pid is the process ID of the Game... HDC hDC = GetDC(NULL); //Here i pass NULL for Entire Screen... HBRUSH hb=CreateSolidBrush(RGB(0,255,255)); SelectObject(hDC,hb); POINT p; while(!kbhit()) { int x=1360/2,y=768/2; MoveToEx(hDC,x-20,y,&p); LineTo(hDC,x+20,y); SetPixel(hDC,x,y,RGB(255,0,0)); SetPixel(hDC,x-1,y-1,RGB(255,0,0)); SetPixel(hDC,x-1,y+1,RGB(255,0,0)); SetPixel(hDC,x+1,y+1,RGB(255,0,0)); SetPixel(hDC,x+1,y-1,RGB(255,0,0)); MoveToEx(hDC,x,y-20,&p); LineTo(hDC,x,y+20); } cin.get(); return 0; } #################################### it works fine....at desktop i see crosshair...but my problem is that when i run game...the cross here got disappeared.... so i think i did not handle the process of game... so i pass the HANDLE to the GetDC(hl)... But GetDC take only HWND(Handle To Window)... so i typecast it like this... HWND hl = (HWND)OpenProcess(PROCESS_ALL_ACCESS,TRUE,pid); and passed hl to the GetDC(hl)... but it doesnt work...Whats wrong with the code... plz tell me how do i make a simple shape at the screen on a process or game... PS : (My Compiler Is DevCPP and OS WinXP SP3....)

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >