Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: sharingViolation error Pin
earl10-Jul-06 5:02
earl10-Jul-06 5:02 
GeneralRe: sharingViolation error Pin
bob1697210-Jul-06 10:52
bob1697210-Jul-06 10:52 
GeneralRe: sharingViolation error Pin
earl10-Jul-06 11:13
earl10-Jul-06 11:13 
QuestionCRichEdit right click Pin
YaronNir8-Jul-06 22:48
YaronNir8-Jul-06 22:48 
QuestionCreating a custom control? Pin
Lord Kixdemp8-Jul-06 16:45
Lord Kixdemp8-Jul-06 16:45 
AnswerRe: Creating a custom control? Pin
Sarath C9-Jul-06 0:50
Sarath C9-Jul-06 0:50 
GeneralRe: Creating a custom control? [modified] Pin
Lord Kixdemp9-Jul-06 14:12
Lord Kixdemp9-Jul-06 14:12 
QuestionHelp calling and using a functions in visual c++ 6 Pin
method0078-Jul-06 12:35
method0078-Jul-06 12:35 
Hi all i am very new to visual c++ . I am using [B]visual studio 6[/B] . So i might ask some simple questions but since i am new i consider you guys bare with me.

I have the following 2 block of codes and i want to be able to call the first one like this :



int pos=-1;
pos=GetPosByNick("name");

I am making a form with a textbox and a button. On the click of the button i want to take the input and place it instead of name in above function call and get the pos value and then use that in my second block of code instead of zero :

(WPARAM)0

so i be happy if an expert tell me step by step what do i need to do to be able to use these blocks of codes. Where to place them , what do i need to declare. Since it is my first attempt to do a program in visual c++ i be happy if an expert give me step by step instrcutions. Thanks





int GetPosByNick(CString szNick) <br />
{ <br />
<br />
HWND hList=NULL;  // List View identifier <br />
<br />
HWND parent,child; <br />
 parent=NULL; <br />
 child=NULL; <br />
 parent = ::FindWindow("My Window Class",NULL); <br />
CString c; <br />
<br />
child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); <br />
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); <br />
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); <br />
child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); <br />
hList=::FindWindowEx(child,0,"SysListView32",NULL); <br />
<br />
<br />
HWND hwnd=parent; <br />
HWND listview=hList; <br />
<br />
   int count=(int)::SendMessage(listview, LVM_GETITEMCOUNT, 0, 0); <br />
   int i; <br />
<br />
   LVITEM lvi, *_lvi; <br />
   char item[512]; <br />
   char *_item; <br />
   unsigned long pid; <br />
   HANDLE process; <br />
<br />
   GetWindowThreadProcessId(listview, &pid); <br />
   process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); <br />
<br />
   _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); <br />
    <br />
   _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); <br />
    <br />
<br />
   lvi.cchTextMax=512; <br />
    <br />
    <br />
   for(i=0; i<count; i++) { <br />
      lvi.iSubItem=2; <br />
      lvi.pszText=_item; <br />
      WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); <br />
      ::SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)_lvi); <br />
<br />
       <br />
      ReadProcessMemory(process, _item, item, 512, NULL); <br />
      //ReadProcessMemory(process, _subitem, subitem, 512, NULL); <br />
       if(item==szNick) <br />
      { <br />
         VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); <br />
          ::CloseHandle(process); <br />
         return i; <br />
      } <br />
       <br />
   } <br />
VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); <br />
 ::CloseHandle(process); <br />
return -1; <br />
<br />
}  



Second block of code:




HWND listview=NULL;  // List View identifier <br />
 HWND parent,child; <br />
 parent=NULL; <br />
 child=NULL; <br />
 parent = ::FindWindow("My Window Class",NULL); <br />
<br />
 child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); <br />
 child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); <br />
 child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); <br />
 child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); <br />
 listview=::FindWindowEx(child,0,"SysListView32",NULL); <br />
<br />
 LVITEM lvi, *_lvi; <br />
 unsigned long pid; <br />
 HANDLE process; <br />
<br />
 GetWindowThreadProcessId(listview, &pid); <br />
 process=OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pid); <br />
   if(process) <br />
   { <br />
    <br />
   _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); <br />
   lvi.mask = LVIF_STATE; <br />
   lvi.state =15; <br />
   lvi.stateMask = LVIS_SELECTED | LVIS_FOCUSED; <br />
<br />
   WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); <br />
   ::SendMessage(listview, LVM_SETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); <br />
   VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); <br />
   } <br />
 ::CloseHandle(process); 

QuestionProblem with 2DGraph of Nikolai Teofilov Pin
ensger8-Jul-06 8:15
ensger8-Jul-06 8:15 
AnswerRe: Problem with 2DGraph of Nikolai Teofilov Pin
Jun Du8-Jul-06 9:46
Jun Du8-Jul-06 9:46 
Questionhow to detect internet connection availability ? Pin
tns_ranjith8-Jul-06 4:20
tns_ranjith8-Jul-06 4:20 
AnswerRe: how to detect internet connection availability ? Pin
includeh108-Jul-06 6:16
includeh108-Jul-06 6:16 
AnswerRe: how to detect internet connection availability ? Pin
PJ Arends8-Jul-06 7:44
professionalPJ Arends8-Jul-06 7:44 
QuestionAvailable/installed RAM Pin
RomTibi8-Jul-06 3:10
RomTibi8-Jul-06 3:10 
AnswerRe: Available/installed RAM Pin
Gary R. Wheeler8-Jul-06 3:54
Gary R. Wheeler8-Jul-06 3:54 
GeneralRe: Available/installed RAM Pin
RomTibi8-Jul-06 5:59
RomTibi8-Jul-06 5:59 
Questionseparating strings [modified] Pin
Tara148-Jul-06 3:01
Tara148-Jul-06 3:01 
AnswerRe: separating strings Pin
Gary R. Wheeler8-Jul-06 3:59
Gary R. Wheeler8-Jul-06 3:59 
GeneralRe: separating strings Pin
Tara148-Jul-06 5:21
Tara148-Jul-06 5:21 
Questionolestd.h , compilation problem in vc++ 7.0 Pin
jalsa G8-Jul-06 1:00
jalsa G8-Jul-06 1:00 
AnswerRe: olestd.h , compilation problem in vc++ 7.0 Pin
Sarath C8-Jul-06 2:20
Sarath C8-Jul-06 2:20 
Questiontoolbar and CColorDialog Pin
TranQuangNhat8-Jul-06 0:56
TranQuangNhat8-Jul-06 0:56 
AnswerRe: toolbar and CColorDialog Pin
Sarath C8-Jul-06 2:26
Sarath C8-Jul-06 2:26 
Questionhow we can get specitfied port is running or not Pin
johnalek8-Jul-06 0:34
johnalek8-Jul-06 0:34 
AnswerRe: how we can get specitfied port is running or not [modified] Pin
Sarath C8-Jul-06 0:47
Sarath C8-Jul-06 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.