Search Results

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

Page 10/30 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • When binding a client TCP socket to a specific local port with Winsock, SO_REUSEADDR does not have a

    - by Checkers
    I'm binding a client TCP socket to a specific local port. To handle the situation where the socket remains in TIME_WAIT state for some time, I use setsockopt() with SO_REUSEADDR on a socket. It works on Linux, but does not work on Windows, I get WSAEADDRINUSE on connect() call when the previous connection is still in TIME_WAIT. MSDN is not exactly clear what should happen with client sockets: [...] For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO_REUSEADDR). Client applications usually need not call bind at all—connect chooses an unused port automatically. [...] How do I avoid this?

    Read the article

  • Windows programming for Unix programmer

    - by Jochen Walter
    I am looking for an introduction to Windows programming. I already have some experience with .net-programming using C#, now I want an overview of the lower-level APIs of Windows. Wikipedia has an article on this subject but, it is quite terse. Is there a canonical book or web site for this kind of information?

    Read the article

  • How can we detect hotkeys registered by other apps?

    - by worlds-apart89
    Is it possible to detect all the hotkeys registered by the OS as well as software applications currently running? Any native or managed approach on the Windows platform? I know that the RegisterHotKey function returns false if the hotkey is already registered, but what I am looking for is an approach, method, etc. that will give me a list of registered hotkeys. Looping all possible combinations with RegisterHotKey does not sound like a good idea. Anything more efficient?

    Read the article

  • Dangers of Windows API and Administrator accounts?

    - by Brett Powell
    I wrote a game server plugin last night that allowed me to create a user account and set it as administrator, which is a huge problem. Of course the simple fix is to create a basic user account with limited privileges for the game servers, so they would not have access to do things like this. I wanted to find out if there's anything else in the Windows API that would create such a huge vulnerability though? I guess I want to just make sure that when the client's game servers accounts are moved to limited access accounts, we won't have to worry about any of them using the windows API to sabotage the machines. There is already enough exploits in the game itself to worry about, without having to worry about client's taking over the machines with plugins lol. Some of the questions relative would be... Can you disable/enable Remote Desktop from c++? Can you get a list of AD user groups from c++? (not that a user belongs to, but a complete list)

    Read the article

  • Is it a good idea to create an STL iterator which is noncopyable?

    - by BillyONeal
    Most of the time, STL iterators are CopyConstructable, because several STL algorithms require this to improve performance, such as std::sort. However, I've been working on a pet project to wrap the FindXFile API (previously asked about), but the problem is it's impossible to implement a copyable iterator around this API. A find handle cannot be duplicated by any means -- DuplicateHandle specifically forbids passing handles to it. And if you just maintain a reference count to the find handle, then a single increment by any copy results in an increment of all copies -- clearly that is not what a copy constructed iterator is supposed to do. Since I can't satisfy the traditional copy constructible requirement for iterators here, is it even worth trying to create an "STL style" iterator? On one hand, creating some other enumeration method is going to not fall into normal STL conventions, but on the other, following STL conventions are going to confuse users of this iterator if they try to CopyConstruct it later. Which is the lesser of two evils?

    Read the article

  • GDI fast scroll

    - by genesys
    Hi! I use GDI to create some custom textwidget. I draw directly to the screen, unbuffered. now i'd like to implement some fast scrolling, that simply pixelshifts the respective part of the framebuffer (and only redraws the newly visible lines). I noticed that for example the rich text controls does it like this. If i use some GDI drawing functions to directly draw to the framebuffer, over a rich text control, and then scroll the rich text, it will also scroll my drawing along with the text. so i assume the rich text simply pixelshifts it's part of the framebuffer. I'd like to do the same, but don't know how to do so. Can someone help? (independant of programming language)) thanks!

    Read the article

  • network windows programming problem

    - by Jayjitraj
    I want to write program which will connect to a network for some amount of time in seconds. Then it disconnects from it and it should be that much faster than the other application (?) should not feel it is disconnected. Which layer should I program at? I know how to disconnect and connect to the network so any suggestion will be helpful...... thanks in advance....

    Read the article

  • Is there a Windows API to modify file type associations for an extension?

    - by JohnFx
    I'm looking for a way to programatically tweak the particulars of a file association on a Windows system. For example, the "Application User to Perform this Action" setting for the "Open" action for a particular file type. Clearly I could do this by modifying the registry directly, but if there is an API I'd prefer to use that as it would likely be more resilient to changes in the OS handling of mapping extensions to applications. For my purposes I'm needing to write this in VBScript (.VBS) file because it is part of a package to be used with VMWare ThinApp that mandates it. However, I'll port/wrap/whatever I need to make this week, so I am open to any solution (including using the .NET framework)

    Read the article

  • ::LookupAccountSid API Extremely Slow When Targetting x64 Platform (Windows 7)

    - by Chris
    During our application startup, we are making a call to ::LookupAccountSid(). When I build targetting the x86 architecture, this call is nearly instantaneous. However, when I target x64 (debug or release), the call generally takes over 40s to complete. Since this is occurring during application startup, the result is fairly unpleasant as it will appear to the user that the application is not launching. I am running Windows 7 Professional 64-bit on a Dell Studio XPS 16 (Intel Core i7 Q 720). Our application is a native Windows application written in C++. My compiler options (CCOPTS) and linker options (LINKOPTS) are as follows: CCOPTS = "/nologo /Gz /W3 /EHs /c /DWIN32 /D_MBCS /Ob1 /vmg /vmv /Zi /MD /DNDEBUG /DDV_BUILD_DLL /DIV_BUILD_DLL /DDVASSERT_EXCEPTION /Zc:wchar_t-" LINKOPTS = "/manifest:no /nologo /machine:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /DEBUG /subsystem:windows /DLL" Any help would be greatly appreciated :D Thanks, --Chris

    Read the article

  • Is it possible to use AnimateWindow with AW_BLEND when using a layered window?

    - by wkf
    I am displaying a window using UpdateLayeredWindow and would like to add transition animations. AnimateWindow works if I use the slide or roll effects (though there is some flickering). However, when I try to use AW_BLEND to produce a fade effect, I not only lose any translucency after the animation (per-pixel and on the entire image), but a default window border also appears. Is there a way to prevent the border from appearing?

    Read the article

  • Changing system colors for a single application (Windows, .NET)

    - by Michal Czardybon
    I know I should generally avoid messing up with such system settings, but my application do already use nonstandard colors and I have no influence on that. I would like to be able to add standard .NET controls in some places, but their colors do not match. I would like to have a hack that would replace system colors for this one application. One more important thing to note is that it is a .NET application. My (incomplete) ideas so far were: To create a proxy User32.dll library with replaced GetSysColor, but it would be very tedious (731 functions to be redirected, 1 to be replaced) and I do not know how to force my application to use that particular copy. To intercept somehow invocations to GetSysColors (unfortunatelly it is somewhere in the CLR I think). To modify somehow .NET class SystemColors (in memory? is it possible?). Do you have any idea, what is the best (and complete) way to achieve this?

    Read the article

  • How to exit SW quickly

    - by Yigang Wu
    I have a SW which reside in external HDD, it will run automatically when user plug external HDD, of course, the SW have to close automatically when user unplug the external HDD. I can receive the device lost message, however my SW will not be respond druing releasing all objects, if I call exit(0) directly, the SW will show a crash message. Is there any way to quickly exit SW?

    Read the article

  • WaitForSingleObject( )

    - by Rakesh Agarwal
    I have got myself stuck into a really amazing issue here.The code is like as below. class A { public: A(){ m_event = CreateEvent(NULL, false, false, NULL); // create an event with initial value as non-signalled m_thread = _beginthread(StaticThreadEntry, 0, this); // create a thread } static void StaticThreadEntry(A * obj) { obj->ThreadEntry(); } void ThreadEntry(); }; void A::ThreadEntry() { WaitforSingleObject(m_event,INFINITE); } int main() { A a; SetEvent(m_event); // sets the event to signalled state which causes the running thread to terminate WaitForSingleObject(m_thread, INFINITE); // waits for the thread to terminate return 0; } Problem : When the above code is run,sometimes( 1 out of 5 ) it hangs and the control gets stuck in the call to WaitforSingleObject()( inside the main function ).The code always calls SetEvent() function to ensure that the thread would terminate before calling Wait() function. I do not see any reason why it should ever hang?

    Read the article

  • How to Disable the Move System Menu Item?

    - by Andreas Rejbrand
    In Microsoft Windows, this works: mnu := GetSystemMenu(h, false); EnableMenuItem(mnu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED); But this does not work: mnu := GetSystemMenu(h, false); EnableMenuItem(mnu, SC_MOVE, MF_BYCOMMAND or MF_GRAYED); Hence I know how to disable the "Close" system menu item of a window, but not the "Move" item. How do I do that? Update Of course one alternative to using the very nice function EnableMenuItem, is to use SetMenuItemInfo: FillChar(info, sizeOf(info), 0); with info do begin cbSize := sizeOf(info); fMask := MIIM_STATE; fState := MFS_GRAYED; end; SetMenuItemInfo(mnu, SC_MOVE, false, info); But this again works perfectly for SC_CLOSE, but not at all for SC_MOVE!

    Read the article

  • Chaining multiple ShellExecute calls

    - by IVlad
    Consider the following code and its executable - runner.exe: #include <iostream> #include <string> #include <windows.h> using namespace std; int main(int argc, char *argv[]) { SHELLEXECUTEINFO shExecInfo; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); shExecInfo.fMask = NULL; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = "open"; shExecInfo.lpFile = argv[1]; string Params = ""; for ( int i = 2; i < argc; ++i ) Params += argv[i] + ' '; shExecInfo.lpParameters = Params.c_str(); shExecInfo.lpDirectory = NULL; shExecInfo.nShow = SW_SHOWNORMAL; shExecInfo.hInstApp = NULL; ShellExecuteEx(&shExecInfo); return 0; } These two batch files both do what they're supposed to, which is run notepad.exe and run notepad.exe and tell it to try to open test.txt: 1. runner.exe notepad.exe 2. runner.exe notepad.exe test.txt Now, consider this batch file: 3. runner.exe runner.exe notepad.exe This one should run runner.exe and send notepad.exe as one of its command line arguments, shouldn't it? Then, that second instance of runner.exe should run notepad.exe - which doesn't happen, I get a "Windows cannot find 'am'. Make sure you typed the name correctly, and then try again" error. If I print the argc argument, it's 14 for the second instance of runner.exe, and they are all weird stuff like Files\Microsoft, SQL, Files\Common and so on. I can't figure out why this happens. I want to be able to string as many runner.exe calls using command line arguments as possible, or at least 2. How can I do that? I am using Windows 7 if that makes a difference.

    Read the article

  • Changing the working directory for a process remotely

    - by Michael
    I've got an application that has a bug right now, but we're unable to update the end-user to get the fix out. What a possible workaround would be is to change the working directory to the application's install directory, but from what I can tell, there's no way to do that outside of the program itself. Is there some sort of Windows API call that can change other processes' working directories, or is that not available due to security issues? I figure it's not possible.

    Read the article

  • Are the *A Win32 API calls still relevant?

    - by Thanatos
    I still see advice about using the LPTSTR/TCHAR types, etc., instead of LPWSTR/WCHAR. I believe the Unicode stuff was well introduced at Win2k, and I frankly don't write code for Windows 98 anymore. (Excepting special cases, of course.) Given that I don't care about Windows 98 (or, even less, ME) as they're decade old OS, is there any reason to use the compatibility TCHAR, etc. types? Why still advise people to use TCHAR - what benefit does it add over using WCHAR directly?

    Read the article

  • Process-wide hook using SetWindowsHookEx

    - by mfya
    I need to inject a dll into one or more external processes, from which I also want to intercept keybord events. That's why using SetWindowsHookEx with WH_KEYBOARD looks like an easy way to achieve both things in a single step. Now I really don't want to install a global hook when I'm only interested in a few selected processes, but Windows hooks seem to be either global or thread-only. My question is now how I would properly go about setting up a process-wide hook. I guess one way would be to set up the hook on the target process' main thread from my application, and then doing the same from inside my dll on DLL_PROCESS_ATTACH for all other running threads (plus on DLL_THREAD_ATTACH for threads started later). But is this really a good way? And more important, aren't there any simpler ways to setup process-wide hooks? My idea looks quite cumbersome und ugly, but I wasn't able to find any information about doing this anywhere.

    Read the article

  • How do I get a window caption?

    - by P.Brian.Mackey
    I would like to get a Window Caption as given by spy++ (highlighted in red) I have code to do this (or so I thought)...but it seems to work pretty awful....in some cases 1% of the time... public delegate bool EnumDelegate(IntPtr hWnd, int lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool IsWindowVisible(IntPtr hWnd); [DllImport("user32.dll", EntryPoint = "GetWindowText", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount); [DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam); static List<NativeWindow> collection = new List<NativeWindow>(); public static NativeWindow GetAppNativeMainWindow() { GetNativeWindowHelper.EnumDelegate filter = delegate(IntPtr hWnd, int lParam) { StringBuilder strbTitle = new StringBuilder(255); int nLength = GetNativeWindowHelper.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1); string strTitle = strbTitle.ToString(); if (!string.IsNullOrEmpty(strTitle)) { if (strTitle.ToLower().StartsWith("window title | my application")) { NativeWindow window = new NativeWindow(); window.AssignHandle(hWnd); collection.Add(window); return false;//stop enumerating } } return true;//continue enumerating }; GetNativeWindowHelper.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero); if (collection.Count != 1) { //log error ReleaseWindow(); return null; } else return collection[0]; } public static void ReleaseWindow() { foreach (var item in collection) { item.ReleaseHandle(); } }

    Read the article

  • C++: Implementing Named Pipes using the Win32 API

    - by Mike Pateras
    I'm trying to implement named pipes in C++, but either my reader isn't reading anything, or my writer isn't writing anything (or both). Here's my reader: int main() { HANDLE pipe = CreateFile(GetPipeName(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); char data[1024]; DWORD numRead = 1; while (numRead >= 0) { ReadFile(pipe, data, 1024, &numRead, NULL); if (numRead > 0) cout << data; } return 0; } LPCWSTR GetPipeName() { return L"\\\\.\\pipe\\LogPipe"; } And here's my writer: int main() { HANDLE pipe = CreateFile(GetPipeName(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); string message = "Hi"; WriteFile(pipe, message.c_str(), message.length() + 1, NULL, NULL); return 0; } LPCWSTR GetPipeName() { return L"\\\\.\\pipe\\LogPipe"; } Does that look right? numRead in the reader is always 0, for some reason, and it reads nothing but 1024 -54's (some weird I character). Solution: Reader (Server): while (true) { HANDLE pipe = CreateNamedPipe(GetPipeName(), PIPE_ACCESS_INBOUND | PIPE_ACCESS_OUTBOUND , PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL); if (pipe == INVALID_HANDLE_VALUE) { cout << "Error: " << GetLastError(); } char data[1024]; DWORD numRead; ConnectNamedPipe(pipe, NULL); ReadFile(pipe, data, 1024, &numRead, NULL); if (numRead > 0) cout << data << endl; CloseHandle(pipe); } Writer (client): HANDLE pipe = CreateFile(GetPipeName(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (pipe == INVALID_HANDLE_VALUE) { cout << "Error: " << GetLastError(); } string message = "Hi"; cout << message.length(); DWORD numWritten; WriteFile(pipe, message.c_str(), message.length(), &numWritten, NULL); return 0; The server blocks until it gets a connected client, reads what the client writes, and then sets itself up for a new connection, ad infinitum. Thanks for the help, all!

    Read the article

  • Stringing multiple ShellExecute calls

    - by IVlad
    Consider the following code and its executable - runner.exe: #include <iostream> #include <string> #include <windows.h> using namespace std; int main(int argc, char *argv[]) { SHELLEXECUTEINFO shExecInfo; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); shExecInfo.fMask = NULL; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = "open"; shExecInfo.lpFile = argv[1]; string Params = ""; for ( int i = 2; i < argc; ++i ) Params += argv[i] + ' '; shExecInfo.lpParameters = Params.c_str(); shExecInfo.lpDirectory = NULL; shExecInfo.nShow = SW_SHOWNORMAL; shExecInfo.hInstApp = NULL; ShellExecuteEx(&shExecInfo); return 0; } These two batch files both do what they're supposed to, which is run notepad.exe and run notepad.exe and tell it to try to open test.txt: 1. runner.exe notepad.exe 2. runner.exe notepad.exe test.txt Now, consider this batch file: 3. runner.exe runner.exe notepad.exe This one should run runner.exe and send notepad.exe as one of its command line arguments, shouldn't it? Then, that second instance of runner.exe should run notepad.exe - which doesn't happen. If I print the argc argument, it's 14 for the second instance of runner.exe, and they are all weird stuff like Files\Microsoft, SQL, Files\Common and so on. I can't figure out why this happens. I want to be able to string as many runner.exe calls using command line arguments as possible, or at least 2. How can I do that? I am using Windows 7 if that makes a difference.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >