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
N

NullStream

@NullStream
About
Posts
29
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • DFS Lookups
    N NullStream

    Sorry this post is from me and by DFS tree I mean (D)istributed (F)ile (S)ystem [not Depth First Search]. I forgot to login before I posted the message.:~ My apologies. Sean

    C / C++ / MFC linux sysadmin data-structures json question

  • Programmatically using WMI to remotely run apps which access locally mapped drives relative to the remote machine.
    N NullStream

    The following code in theory should pop up a CMD window and show me the contents of a mapped drive mapped locally on a remote machine called "remote_workstation_a". I'm running this script from my workstation and when I do the CMD window pop's up and tells me access denied. I tried logging in on the local machine as the domain administrator then run this script again with no luck. I can't seem to figure out programmatically how to connect to a remote machine with a specific username and password yet still access the Win32_Process WMI object. strComputer = "remote_workstation_a" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process") Error = objWMIService.Create("cmd.exe /K dir w:\", null, null, intProcessID) If Error = 0 Then Wscript.Echo "was started with a process ID of " _ & intProcessID & "." Else Wscript.Echo " could not be started due to error " & _ Error & "." End If I know this is possible because there are tools that already exist (psexec and beyondexec naming two) that can do this. As an example with PSEXEC (from sysinternals.com): psexec \\remote_workstation_a -u MY_PDC_DOMAIN\Adminstrator -p PASSWORD -i cmd.exe /K dir w:\ This works so I know for certain this is possible I can't can't find anything clear in the WMI docs on MSDN to show me how to do this. Based on this I just need to encode the username and password of the account I would like to impersonate on the remote machine somehow (through the 'GetObject("winmgmts:" ...' call?). The obvious answer is to just use PSEXEC but I need to run this a whole lot of times (which would open up MANY MANY processes) and PSEXEC's source is not exactly available. Any hints or suggestions would be greatly appriciated. The whole point of me attempting this is to make the tech guy's life a bit easier when pushing updates to the compute farm. And while I'm at it why is all the WMI documentation so vague on almost everything? I'm eventually going to need to map a printer to each machine on the network and I'd love to do it though WMI but it's going to be a BIG BIG chore without some insight. Thanks, Sean

    System Admin tools tutorial com sysadmin help

  • TreeView_GetParent
    N NullStream

    I feel like such a choad. Out of all the Win32 Common Controls the TreeView control has given me the most grief and the documentation is not very helpful. In this instance (of a long series of them) I'm having a problem with the TreeView_GetParent function. Basically I'm trying to follow a leaf in the tree back to it's root. And do so via the following function: void ConstructPath(TVITEM *item,char *buffer) { // Follow parentage. HTREEITEM back = TreeView_GetParent(Tree,item->hItem); if(back == NULL) { MessageBox(MainWindow,"doesn't have parent","recursed",0); } else { TVITEM *node = (TVITEM *)back; // problem must be here. char name[_MAX_FNAME]; memset(&name,0,_MAX_FNAME); node->mask |= TVIF_TEXT | TVIF_CHILDREN ; node->pszText = (char *)&name; node->cchTextMax = _MAX_FNAME; TreeView_GetItem(Tree,node); MessageBox(MainWindow,name,"recursed",0); ConstructPath((TVITEM*)back,buffer); // Recurse with parent node. } } When run this function screws up the display of the control and returns the absolutely wrong nodes in the tree. Now I'm going to hazzard an educated guess that "TVITEM *node = (TVITEM *)back;" is the problem as back is an HTREEITEM that I'm casting to a TVITEM (which TreeView_GetParent requires yet returns a HTREEITEM. I cannot find the definition of HTREEITEM in the help system and hoping that GetParent was written with recursion in mind the two types might not have been far off (I know bad guess X| ). Can anyone tell me what the relationshipo is between TVITEM and HTREEITEM and how I can convert one into the other (or at least point me to some clear documentation)? :confused: Sean

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

  • Memory Tracking
    N NullStream

    Well I did that and it stated I had no leaks in the application. Maybe I'm just trusting the Task Manager when I shouldn't be. Sean

    C / C++ / MFC c++ data-structures tools performance question

  • Memory Tracking
    N NullStream

    instead). Again the memory usage still rises (by about 4KB mind you [if the task manager can be believed... most of my memory allocation is of the single MAX_PATH and _MAX_FNAME chunks). Now thinking it could be from pass by value allocation I made sure and passed all my buffers by reference and yet it still rises. (eg MessageBox(MainWindow,(char*)&buffer,"cannot open item",0);) My last shot in the dark is maybe MessageBox is creating the leak by when clicking OK the message box is not freed by Windows or something. I know that's a stretch but I can't think of anything else. Are there any tools out there that I can use to determine where memory is being allocated and find possible leaks? (mind you I'm using char*'s and straight Win32SDK (aka no mfc)). Can anyone suggest what I can look for next? :confused: This is driving me absolutely batty. :mad: Sean

    C / C++ / MFC c++ data-structures tools performance question

  • Win32 Tree Question
    N NullStream

    That's exactly what I'm looking for and using GetParent doesn't sound as messy as a tree comparisson unless of course the control itself doesn't handle it well. I'd have to do a recursive match either way so I'll let the control do most of the work. Thanks a million none the less. :-D Sean

    C / C++ / MFC c++ data-structures debugging question learning

  • Win32 Tree Question
    N NullStream

    Ok. That seem to do it and according to the help file I ended up with: HWND ctrl = GetDlgItem(MainWindow,IDC_TREE); char buffer[1024]; memset(buffer,0,1024); if(ctrl == NULL) MessageBox(MainWindow,"GET TREE","Selection CHANGED!",0); node->itemNew.mask |= TVIF_TEXT; node->itemNew.pszText = buffer; node->itemNew.cchTextMax = 1024; if(TreeView_GetItem(ctrl,&node->itemNew)) MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0); This works fine but it seems from the Help files regarding TVITEM suggest than I can only "tell" if an item has a child. Is there a way to use the control itself to follow the lineage of the selected item? For arguments sake let's just say i'm trying to implement a file browser (not the case but the same idea). If I choose a file I need to build up the entire path based on the selection back to through the parents to the root. Do I have to "already know" the structure of the tree already? Having two copies (one in the tree control itself and the other in my program) of the same tree in memory seems to be a waste and terribly inefficient which is why I'm trying to just use the data in the treecontrol instead of building a tree data structure in memory which is replicated to the treecontrol. Man that's wierdly stated hopefully I'm making some sort of sense here. X| Sean

    C / C++ / MFC c++ data-structures debugging question learning

  • Win32 Tree Question
    N NullStream

    Unfortunately, even with that problem still occurs. :L Sean

    C / C++ / MFC c++ data-structures debugging question learning

  • Win32 Tree Question
    N NullStream

    It seems that when I add to a TreeControl (Win32 SDK not MFC) the pszString item I add is not the same was what I put in (eg. Put in text and get back a large string of hi-ascii). I insert into the tree thusly: TVINSERTSTRUCT tvs; TVITEM tvi; HTREEITEM last; tvs.hInsertAfter = TVI_LAST; tvi.mask = TVIF_TEXT; tvi.pszText = "Test Item #1"; tvs.hParent = TVI_ROOT; tvs.item = tvi; last = TreeView_InsertItem(GetDlgItem(MainWindow,IDC_TREE),&tvs); To retrieve I handle the WM_NOTIFY message when the event is TVN_SELCHANGED. case WM_NOTIFY: node = (LPNMTREEVIEW)lParam; if(node->hdr.code == TVN_SELCHANGED) { MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0); } break; In the debugger node->itemNew.pszText is high ascii garbage and no where near the "Test #1" item I put in. The book I have and the docs I've found so far all use the TreeControl by comparing the selected item to a list of the items added which is no good for me because I'm trying to build up the entire path from each selected tree item (like a file path). This occurs with multiple items in the tree control as well. Any suggestions or ideas on where I have gone wrong would be greatly appricated. Sean

    C / C++ / MFC c++ data-structures debugging question learning

  • Resizing controls.
    N NullStream

    I'm working on a small project which requires 2 controls to fit in a window and be resized with sizes being relative to the size of the window and the other control. First I'll state that I'm using only Win32 in plain old C and the controls in question are a Dialog Box which contains a tree control and a text control. I guess I'll split my question into two parts. 1) What is the standard way of dealing with window resizing and contained controls. Dealing with 1 control is easy though any more and you have to deal with some math and possible diagrams just to make sure the resizing operation works as one might expect. 2) I've seen in some applications partitions between controls which let you resize adjacent controls based on left/right or up/down movement (sorry I have no clue what they are called). Does such a thing exist in the Win32 libraries or do I have to come up with it on my own. If I have to come up with it on my own I was thinking of using a plain button as I already know how to work with those. Does anyone have any suggestions or ideas how to solve this rather old yet simple problem?:confused: Sean

    C / C++ / MFC question data-structures help tutorial

  • Article Ideas
    N NullStream

    Probably a case of mistaken identity and fuzzy memory. I know one of the Microsoft Press authors expired though I can't remember which one. :P Sean

    Article Writing visual-studio csharp c++ graphics game-dev

  • Article Ideas
    N NullStream

    I have that book though it is rather dated and does not include any APIs other than Win95. AFAIK the author may have kicked the proverbial bucket so updates are probably not forthcomming. Sean

    Article Writing visual-studio csharp c++ graphics game-dev

  • Article Ideas
    N NullStream

    I tend to use Windows as resource intensive dumb terminal that also lets me play fancy games now and then. Until recently I've been rather satisfied with that but am wanting to make a bit more use of it which brings me to subject of this post. A few suggestions of articles I've been looking for but have yet to find: 1) Using the Visual Studio command line tools instead of the IDE (otherwise known as: when vi is just good enough for me). 2) More Non-MFC oriented tutorials (which are becoming harder and harder to come by). I tend to want to understand the Win32 SDK before relying on toolkits based on it. 3) Up to date tutorials on using the DirectX set of libraries (just looking at the sparse documentation makes me wonder why it is so needlessly complex). I'm not looking to write "mad g4m3z" but rather visualize data and possibly play around with sounds. I would write such articles myself once I've figured the various topics out but my experience lies more in the UNIX realm so I'm a fish out of water here. :confused: Sean

    Article Writing visual-studio csharp c++ graphics game-dev

  • Windows begetting other windows.
    N NullStream

    I just saw that myself. Basically I have 2 windows. Window #1 is a configuration window which accepts parameters for how Window #2 will work. Window #2 is just going to be a clean window which will have a DirectDraw surface on which I can paint via the options in Window #1. Now when Window #1 launches Window #2 I want it to go away as Window #2 will become the main window. When Window #2 closes the application closes. Is that too confusing? X| Sean Cody (NullStream) "Today is what ever I want it to mean." - Beth Orton

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

  • Windows begetting other windows.
    N NullStream

    Windows XP and Visual Studio 6 SP5. Ok. I think my problem is coming due to a misunderstanding of how things are supposed to work. For any Win32 program you create a main window. You have to programmatically add any controls you want to this window. I was/is trying to create the main window yet fill it's contents with a dialog I made in the resource editor. Is this even possible? Then I would create another window in the same fashion and it doesn't show.... ugh. :mad: one day i'll see it.... but i don't think it will be today. Sean Cody (NullStream) "Today is what ever I want it to mean." - Beth Orton

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

  • Windows begetting other windows.
    N NullStream

    I can send code upon request as the code to generate and show the 2 windows is larger than it is appropriate to post to this forum. Sean Cody (NullStream) "Today is what ever I want it to mean." - Beth Orton

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

  • Windows begetting other windows.
    N NullStream

    I've been trying this for hours but I can't seem to get one main window to create and show another separate window at run time. ShowWindow() returns no error yet the new window still does not show. I'm very confused. Would someone be so kind as to write up a small snippet of code in which one open window creates an opens a second detached window so I can see what exactly it is I'm missing. I'm doing this in C only and using the base Win32 SDK and not MFC (which I won't even attempt until I understand how to effectively use the base Win32 SDK first). I can understand if someone doesn't want to write up a litte piece of code but if all else fails can some one direct me towards a document or website that can? All the documentation I have thus far explain how to use single windows and unique dialogs but not multiple windows. As well is there some macro I could use to print out debug statments (like what return values are without printing out a MessageBox() for everything? I apologize for my ignorance and stupidity and thank you all in advance. Sean Cody (NullStream) "Today is what ever I want it to mean." - Beth Orton

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

  • Clipboard CRLF & Control Fonts
    N NullStream

    I'll look into that. Thanks again. Sean Cody

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

  • Clipboard CRLF & Control Fonts
    N NullStream

    I should have specified I am only using C and the bare Win32 API (no MFC) so that method will not work for me. :( Though the fopen suggestion worked great. Thanks! Sean Cody

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

  • Clipboard CRLF & Control Fonts
    N NullStream

    I have 2 questions the first is there a simple way to change the font size of a particlar control (eg. listbox). The second is that I have a simple function (attached) which just reads a file and places it's textual contents into the clipboard. When I paste the info in notepad it is one continuous line with the crlf characters a little boxes though if i paste into other things (like in visual studio) it is fine. Is there some way I can preserve the carriage return/line feeds in the clipboard so that pasting into notepad and anything else will have the proper contents of the file?

    // function is cut down to limit the spaming of useless code
    EmptyClipboard();
    GlobalBuff = GlobalAlloc(GMEM_MOVEABLE,size+1);
    
    buffer = (char*)GlobalLock(GlobalBuff);
    while(!feof(file)) {
         fread(readbuffer,1,255,file);
         if(ferror(file)) {
              MessageBox(NULL,strerror(errno),"Error",MB_ICONERROR);
              exit(1);
         }
         strcat(buffer,readbuffer);
         memset(readbuffer,0,strlen(readbuffer));
    }
    
    GlobalUnlock(GlobalBuff);
    if(SetClipboardData(CF_TEXT,GlobalBuff) == NULL) 
         return FALSE;
    CloseClipboard();
    

    If posting of this code is not appropriate please let me know and forgive my insolence. Any help or suggestions are greatly appricated. Thanks, Sean Cody

    C / C++ / MFC help csharp visual-studio 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