Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 8th, 2006, 05:19 PM
ehsanking ehsanking is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 207 ehsanking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 3 m 51 sec
Reputation Power: 4
Talking Help calling and using a functions in visual c++ 6

Hi all i am very new to visual c++ . I am using visual studio 6 . 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



Code:
int GetPosByNick(CString szNick) 
{ 

HWND hList=NULL;  // List View identifier 

HWND parent,child; 
 parent=NULL; 
 child=NULL; 
 parent = ::FindWindow("My Window Class",NULL); 
CString c; 

child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); 
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); 
child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); 
child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); 
hList=::FindWindowEx(child,0,"SysListView32",NULL); 


HWND hwnd=parent; 
HWND listview=hList; 

   int count=(int)::SendMessage(listview, LVM_GETITEMCOUNT, 0, 0); 
   int i; 

   LVITEM lvi, *_lvi; 
   char item[512]; 
   char *_item; 
   unsigned long pid; 
   HANDLE process; 

   GetWindowThreadProcessId(listview, &pid); 
   process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_V  M_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION,   FALSE, pid); 

   _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); 
    
   _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); 
    

   lvi.cchTextMax=512; 
    
    
   for(i=0; i<count; i++) { 
      lvi.iSubItem=2; 
      lvi.pszText=_item; 
      WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); 
      ::SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)_lvi); 

       
      ReadProcessMemory(process, _item, item, 512, NULL); 
      //ReadProcessMemory(process, _subitem, subitem, 512, NULL); 
       if(item==szNick) 
      { 
         VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); 
          ::CloseHandle(process); 
         return i; 
      } 
       
   } 
VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); 
 ::CloseHandle(process); 
return -1; 

} 



Second block of code:


Code:
HWND listview=NULL;  // List View identifier 
 HWND parent,child; 
 parent=NULL; 
 child=NULL; 
 parent = ::FindWindow("My Window Class",NULL); 

 child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); 
 child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); 
 child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); 
 child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); 
 listview=::FindWindowEx(child,0,"SysListView32",NULL); 

 LVITEM lvi, *_lvi; 
 unsigned long pid; 
 HANDLE process; 

 GetWindowThreadProcessId(listview, &pid); 
 process=OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pid); 
   if(process) 
   { 
    
   _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); 
   lvi.mask = LVIF_STATE; 
   lvi.state =15; 
   lvi.stateMask = LVIS_SELECTED | LVIS_FOCUSED; 

   WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); 
   ::SendMessage(listview, LVM_SETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); 
   VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); 
   } 
 ::CloseHandle(process); 

Reply With Quote
  #2  
Old July 28th, 2006, 07:24 PM
kritimehrotra kritimehrotra is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 6 kritimehrotra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 24 sec
Reputation Power: 0
Hi,

I should point out I haven't used visual studo 6, so I am giving a general concept of what you should do, you might have to find the correct syntax. Sorry!

For the first part:
Declare a variable of type string, something like...
string txtValue;
and set it equal to the text in the textbox. if your textbox is name txt1, it should look like...
txtValue = txt1.Text; or txtValue = txt1.Value;
(again, not sure about syntax)

then call your function using this variable...
pos=GetPosByNick(txtValue);



I am not completely sure about the second part, but you should be able to just do ...
(WPARAM)pos


let me know if any of this is helpful!

sincerely,
kriti

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Help calling and using a functions in visual c++ 6


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway