Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

JT Anderson

@JT Anderson
About
Posts
59
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What's the deal with Namibia
    J JT Anderson

    I've been working on some code to convert times between time zones. I noticed that "Namibia Standard Time" (Windhoek) has a positive value (60) for DaylightBias. It is alone in this regard, all other time zones defined in the registry have -60 as the DaylightBias. Since Namibia is in the southern hemisphere, one would expect Daylight Time to begin near the end of the year and Standard Time to begin early in the year. They also have this turned around for this particular time zone. So, it all sort of works out, but seems odd. Anyone know why Microsoft defined "Namibia Standard Time" differently from other time zones in the southern hemisphere that observe Daylight Saving Time?

    -------- There are 10 types of people in this world. Those who know binary and those who don't.

    IT & Infrastructure windows-admin question

  • SQL Server authentication problem
    J JT Anderson

    We have four systems, which I will designate as follows: MySvr1 - Windows Server 2003 - MSDE 2000 SP3 MySvr2 - Windows Server 2003 - MSDE 2000 SP3 DbSvr1 - Windows Server 2000 - SQL Server 2000 SP3 DbSvr2 - Windows Server 2003 - SQL Server 2000 SP3 All of these systems are members of a domain that I'll call DOMAIN. MySvr2 has a service running under the local system account. This service wants to access a database using its domain computer account. We've created a security group (call it SecGroup) that includes DOMAIN\MySvr2$ among its members. We've created a database login for SecGroup on all four servers. The service running on MySvr2 attempts to connect to the database using the connect string: Provider=sqloledb;Integrated Security=sspi;Initial Catalog=MyDatabase;Data Source=servername If the service attempts to connect to the database on MySvr2 or MySvr1 it succeeds. Furthermore, if I remove the SecGroup login on MySvr1 and try to connect, I get a login error message that indicates login failure for "DOMAIN\MySvr2$". This is exactly what I would expect and hope for. If we attempt to connect to the database on DbSvr1 we get a login failure: IDispatch error #3149 Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. If we attempt to connect to the database on DbSvr2 we get a login failure: Unspecified error Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. As one more test, we created a share on DbSvr1 with a file in it. We put an ACL on the share, the underlying folder, and the file, that granted access only to members of SecGroup. When I tried to access the file from MySvr2, while logged in as myself, I got access denied (as expected). When the service tried to access the file it was able to do so, and we could verify that it had authenticated to DbSvr1 as DOMAIN\MySvr2$. The TCP/IP transport is enabled on all four servers. Anyone have any ideas as to what could be causing this? Any remedies? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    Database database security help sql-server sysadmin

  • How can I tell if I'm running as a service?
    J JT Anderson

    I have an application that should be able to run either as a service or as a user mode application. Currently, I call StartServiceCtrlDispatcher and if it fails (error 1063) I run as user mode. But, StartServiceCtrlDispatcher often takes several seconds before it fails when I'm running the app in user mode, causing an annoying startup delay. Can someone suggest a fast way to tell whether or not my application is being started as a service? (Please do not suggest using command line options.) -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question help

  • Why is my overlapped WriteFile blocking?
    J JT Anderson

    I have a named pipe client that is using overlapped I/O on a handle registered with an I/O completion port. There was a bug in the server that was causing it to never read the named pipe, which in turn caused me to notice that the overlapped WriteFile call in the client was getting blocked. My overlapped ReadFile calls are not being blocked. After fixing the server bug, it appears that the WriteFile calls are always completing before WriteFile returns. I never seem to get ERROR_IO_PENDING back on a write. The write completion events ARE being properly posted to the IOCP. I did open the named pipe with FILE_FLAG_OVERLAPPED. (If I hadn't, I don't think the overlapped reads would be working properly.) Any suggestions? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC help sysadmin question

  • Network availability change events
    J JT Anderson

    Thanks. I knew there was another way that I'd stumbled across a while back, and that was it. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC sysadmin json question

  • Network availability change events
    J JT Anderson

    I need a way to detect when network connections (LAN, dial-up, wireless, etc.) become available or unavailable. The NotifyAddrChange function in the IP Helper API seems to do what I need, but I was wondering if there were any alternatives that I should explore. Any suggestions? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC sysadmin json question

  • Overlapped Connect
    J JT Anderson

    Thanks. I see it requires XP or later, but that might be acceptable. At first I wondered how I could have missed it, but then when I see where it was hidden in the Oct 2001 MSDN library (I'm still using VC6) I won't beat myself up too badly. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question

  • Overlapped Connect
    J JT Anderson

    As far as I can tell, WSAConnect doesn't use OVERLAPPED, so it doesn't play that well with an I/O completion port. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question

  • Overlapped Connect
    J JT Anderson

    I'm working on a Winsock application using I/O completion ports. I can't find any flavor of connect() that uses OVERLAPPED I/O. Am I missing something? Any clever work-arounds? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question

  • Disappearing list controls
    J JT Anderson

    It was being called after I was done adjusting the visibility and Z-order of the child dialogs but before the message pump was allowed to run. I'm pretty sure it was the last thing to happen before returning to the message pump. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC tutorial question

  • Disappearing list controls
    J JT Anderson

    Thanks for the response. I actually found the apparent "what was causing this", but I still don't understand the "why". I had a call to SetFocus that was setting the focus to the list control (before it would have been painted). Removing this SetFocus call appears to have solved the problem. I had used Spy++ to look at the WM_PAINT and WM_ERASEBKGND messages. In agreement with your posting, the order of messages didn't make much sense and would fairly clearly cause the problem I experienced. If anyone has any insight on the "why" of this problem, curiosity is killing this cat. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC tutorial question

  • Disappearing list controls
    J JT Anderson

    I have a dialog based application. The main dialog contains a tab control and several child dialogs, one per tab on the tab control. (The child dialogs are children of the main dialog, not of the tab control.) When a tab is selected, I hide the currently visible child dialog, move the child dialog associated with the newly selected tab so that it immediately follows the tab control in the Z-order, and make the newly selected child dialog visible. This all seems to work fine, except sometimes list controls in the child dialogs disappear. I say they disappear, because they do get drawn, but are immediately erased. If I start clicking on portions of the list control, pieces of it will be drawn. For example, if I click on an item, the item will be drawn. If I click on a scroll bar, the scroll bar will get drawn. Any ideas? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC tutorial question

  • How to convert a pointer to char*?
    J JT Anderson

    How about this: #include void main() { int iVar; void *pVar = &iVar; std::cout << pVar << std::endl; } -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC c++ help tutorial performance question

  • Problem when executing this code
    J JT Anderson

    You're mixing iostreams (cout) and stdio (gets), so the streams are not synchronized. This should work: #include "iostream.h" #include "stdio.h" #include "string.h" int main() { char str[80]; cout << "Enter a sentence: "; cout.flush(); gets (str); cout << "\nYou entered: " << str; return 0; } As should this: #include #include int main() { std::string str; std::cout << "Enter a sentence: "; std::getline(std::cin, str); std::cout << "\nYou entered: " << str; return 0; } (But, for some reason I don't understand, the latter requires you to hit enter twice.) -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC help question announcement

  • fault on delete[ ] ?
    J JT Anderson

    Actually, free(NULL) is safe on any standard C compiler. There were certainly old, pre ANSI C, compilers that didn't handle free(NULL) well. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC csharp visual-studio game-dev help question

  • Load order of implicitly linked DLLs
    J JT Anderson

    The DELAYLOAD linker option, perhaps? -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC windows-admin question

  • WaitForSingleObject
    J JT Anderson

    I may be making a rash statement here, but this looks like a job for a semaphore, rather than an event. Create a semaphore with an initial count of 0 and a huge max count (LONG_MAX or something like that). Each time a writer puts something in the queue, it calls ReleaseSemaphore. The reader(s) wait on the semaphore and remove one item from the queue each time they wake up. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question com data-structures

  • screensaver problem
    J JT Anderson

    If you want to start the currently configured screensaver, try this: PostMessage(GetForegroundWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0); -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC help c++ algorithms

  • [win32]ListView doesn't generate VK_RETURN
    J JT Anderson

    Well, you may not be able to use the code, but you can still use the concept. You can subclass (in the Windows sense, not the C++ sense) the ListView control and handle the WM_GETDLGCODE message. There may be more (seemingly) expedient ways to work around your problem, such as peeking the message loop or playing games with the default button, but I don't know of any ways more correct than handling WM_GETDLGCODE as I suggested. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question

  • [win32]ListView doesn't generate VK_RETURN
    J JT Anderson

    Aha! I was going to set out to prove you wrong about that, but now think I know what your problem is. Your CListCtrl is in a dialog, right? As some of the other responses may have suggested, the dialog is eating your VK_RETURN messages. I suggest that you derive a class from CListCtrl and add a WM_GETDLGCODE handler something like this:

    UINT CListCtrlEx::OnGetDlgCode()
    {
    const MSG *pMsg = (const MSG *)GetCurrentMessage()->lParam;

    if (pMsg != NULL &&
        pMsg->message == WM\_KEYDOWN &&
        pMsg->wParam == VK\_RETURN) {
         return DLGC\_WANTMESSAGE;
    }
    
    return CListCtrl::OnGetDlgCode();
    

    }

    Assuming that you want the same thing to happen for double-clicks and the enter key, you should handle LVN_ITEMACTIVATE. If you want to do something different, then this change should get the WM_KEYDOWN/VK_RETURN to your list control. -------- There are 10 types of people in this world. Those who know binary and those who don't.

    C / C++ / MFC question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups