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
D

dellthinker

@dellthinker
About
Posts
91
Topics
56
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • GetForegroundWindow()
    D dellthinker

    Thanx Mark, your solution worked. :)

    C / C++ / MFC question help

  • GetForegroundWindow()
    D dellthinker

    Ok so now im using GetWindowText() and it seems to capture all window titles. But i need it to look for a specific window, Notepad in this case. Here is my code: #include #include using namespace std; int main(void) { HWND currenthwnd,hwnd; char s[1024]; hwnd=NULL; while (1){ Sleep(1000); currenthwnd=GetForegroundWindow(); if (currenthwnd!=hwnd){ hwnd=currenthwnd; GetWindowText(hwnd,s,1024); printf("%s\n",s); } if(strstr(s, "Notepad") == 0){ cout << "Notepad is open! " << endl; } else{ cout << "Its not open " << endl; } } return 0; } Problem is when the program is running it prints Notepad is open when it really isnt. Can someone help me fix this? Thanx in advance!

    C / C++ / MFC question help

  • GetForegroundWindow()
    D dellthinker

    Hi all. Im trying to find out whether a window is active or not. This is what i have so far... #include #include using namespace std; int main(){ Sleep(1000); if(strcmp("00315434", GetForegroundWindow()) == 0){ cout << "Notepad found! " << endl; } return 0; } But i get an error. error C2664: 'strcmp' : cannot convert parameter 2 from 'struct HWND__ *(__stdcall *)(void)' to 'const char *' How do i compare what GetForegroundWindow returns so i can make my app look for a specific window? Thanx in advance!

    C / C++ / MFC question help

  • Hooking
    D dellthinker

    Hi all, i found this example on MSDN. Im trying to find out how i can accomplish what im trying to do, and thats monitor the events of a application. So here's the code... #include int main(){ HOOKPROC hkprcSysMsg; static HINSTANCE hinstDLL; static HHOOK hhookSysMsg; hinstDLL = LoadLibrary((LPCTSTR) "c:\\windows\\notepad.dll"); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc"); hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0); return 0; } I've noticed that i dont have notepad.dll - It may not be new to some but it is to me seeing how i've never had to look for it. So what would i have to do to monitor notepads events? Also, what char would i dump the messages from to a fstream .txt file? Thanx in advance!

    C / C++ / MFC tutorial question

  • Linker error
    D dellthinker

    Hi all, i've played with/search for a solution and gotten frustrated over a problem that i have with a piece of code and i cant seem to get it down for some retarded reason. The error is this: error LNK2001: unresolved external symbol "int __cdecl brandom(int,int)" (?brandom@@YAHHH@Z) The code its talking about is #include #include "header.h" using namespace std; int dport = brandom(1900, 48000); int main(){ int dport = brandom(1900, 48000); cout << dport << endl; return 0; } #ifndef __RANDOM_H__ // Contents of header.h #define __RANDOM_H__ void init_random(); int brandom(int client,int top); int get_random_number(int range); #endif I've been to msdn about this stupid problem and yet i cant find out a way to resolve this. Can anyone help? Thanx in advance!

    C / C++ / MFC help question

  • file help
    D dellthinker

    Sarath. wrote:

    I can't figure out what you are really trying to do.

    "My goal here is to copy the currently used file. Then start the new file and delete the old one." I've already said that, i _know_ the code is wrong. Im asking for help in trying to fix it.

    C / C++ / MFC help announcement

  • file help
    D dellthinker

    Hi all. My goal here is to copy the currently used file. Then start the new file and delete the old one. An update sequence if you will. My code: #include #include using namespace std; int main(int argc, char *argv[]) { char *file="program.exe"; char *currentfile = argv[0]; CopyFile(currentfile, file, FALSE); if(file == currentfile){ Sleep(8000); DeleteFile(argv[1]); } else{ ShellExecute(0,"open", file, argv[0], 0, SW_SHOW); exit(1); } return 0; } Im stumped trying to figure this out. Any suggestions will be accepted (as long as their helpful =P). I think its trying to delete itself, which is 'not' what im trying to do. So if anyone can help me figure out what im doing wrong i'd be very greatful. Thanx in advance!

    C / C++ / MFC help announcement

  • Help
    D dellthinker

    Hi all. Im going to try my best in explaining on what i need. I have a program that downloads an update to the package. I havnt gotten so good that i can update the file with out stopping or closing it but this is the only solution i could come up with. In order for the new program to work the old one has to download it. Then open it. I used ShellExecute() to open the new program. Thats not the problem though. Well now that i have the new program in the install folder, i need to kick the old one. So what im trying to do is get it to delete any files that opened it. I'll make a brief description. old-file.exe opens new-file.exe new-file.exe starts up and deletes old-file.exe I cant make it any simple than that. I thought by using argv that would be a start in figuring it out but i dont know how. Any suggestions? Thanx in advance!

    C / C++ / MFC help question announcement

  • FtpPutFile problem
    D dellthinker

    Sorry i read that wrong. The file on my machine was 1kb. And before i added the INTERNET_FLAG_PASSIVE argument it would upload the file, but on the ftp server it would be 0KB when the original file was 1kb

    C / C++ / MFC com sysadmin help question

  • FtpPutFile problem
    D dellthinker

    Well that seemed to do the trick. However i ran Wireshark and it doesnt exactly request PASV before sending. *shrugs* We dont explain why it works that way. It just works! Thanx for your replies, i've been at it for ages and now i can finally move on to the next option task :)

    C / C++ / MFC com sysadmin help question

  • FtpPutFile problem
    D dellthinker

    DavidCrow wrote:

    So is the source file empty?

    Yes, as in 0 bytes. And how do i open it in passive mode? I didnt see an option for it.

    C / C++ / MFC com sysadmin help question

  • FtpPutFile problem
    D dellthinker

    Hi all. I've tried to use this but it doesnt seem to work. One time i tried it and it worked very well. The second time i tried it it didnt work. What it does is it connects well and sends the file. But problem is that there is nothing in the text file. Here is what i have so far. #include #include #include using namespace std; void FileSubmit() { char *user="user"; char *pass="password"; char *ftpserver="ftp.server.com"; HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession, "C:\\test.txt", "file.txt", FTP_TRANSFER_TYPE_ASCII, 0) == TRUE){ cout << "File Sent! " << endl; Sleep(1000); InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); } else{ cout << "File didnt send " << endl; } } int main(){ FileSubmit(); return 0; } I know text files need to be sent in ASCII mode so i switched to that and it still didnt work. It uploads the file but the file is empty. Whats going on??? Thanx in advance!

    C / C++ / MFC com sysadmin help question

  • Simple FTP Client
    D dellthinker

    Peter Weyzen wrote:

    You could have answered "no". But you had to get made and respond with 4 times as many words as I did. You also were not clear in your intent. I tried to help. Lame-o!

    First of all my intention was already said hence the topic of the thread. But since i have to spell it out for you then i'll do that. Im Trying To Make A FTP Client That Uploads. Not Something That Downloads. Im Only Trying To Get It To Upload. I hope that was simple enough. Second of all, for the second poster. Its not my intention to flame anyone or be a jerk. My goal is to figure something out. If you were going to provide helpful suggestions then I would have gladly accepted it. But if your going to ask lame questions like "why dont i just use another FTP client" when i clearly said im trying to 'learn' how to make one. Well then how would you reply if the tables were turned?

    C / C++ / MFC html sysadmin help

  • Simple FTP Client
    D dellthinker

    Peter Weyzen wrote:

    Are you doing it this way because you don't want to use the support already in windows to do this? It's fairly easy...

    Its off topic questions like these that annoy the common person trying to accomplish something. But if you must know why I'm attempting to do this is because i want to. Now if you have a solution to the issue at hand please feel free to offer some advice based on the question. Does anyone else have a educational solution pertaining to the issue at hand? Thanx in advance!

    C / C++ / MFC html sysadmin help

  • Simple FTP Client
    D dellthinker

    Hi all. Im trying to make a simple FTP client that uploads files. Again im trying to make a client that uploads files and not downloads. I specified that so that we could get an understanding of what im trying to do here. Anyway i was refered to a site that deals with programming for FTP Servers. Heres the url: http://www.stanford.edu/class/ee284/pa.html he instructions were written for a UNIX programming but WinSock supports all the functions it calls for. The functions are the following: socket() bind() listen() getsockname() accept() Mind everyone finding a simple way to use these functions is NOT a simple task. But after spending countless hours using google/yahoo i came up with the following code: #include #include using namespace std; #define port 21 bool ftpmsg(const char *message); SOCKET dataSock; SOCKET socketbuffer; int main(){ const int SIZE=100; char msg[SIZE]; char server[SIZE]; char recvbuffer[900]; WORD wVersionRequested; SOCKADDR_IN addr; WSADATA wsa; struct sockaddr_in structSock; struct hostent *ftpserveraddy; wVersionRequested=MAKEWORD(2, 0); WSAStartup(wVersionRequested, &wsa); dataSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); printf("Please enter the Host name to connect to:"); cin.getline(server, SIZE); printf("Connecting to FTP Server: '%s'\n",server); if((ftpserveraddy = gethostbyname(server)) == NULL){ printf("DNS Lookup of '%s' failed!\n",msg); } structSock.sin_family = AF_INET; structSock.sin_port = htons(port); structSock.sin_addr.s_addr = *((unsigned long*)ftpserveraddy->h_addr_list[0]); memset(structSock.sin_zero, 0, 8); if(connect(dataSock, (sockaddr*)&structSock, sizeof(sockaddr)) == SOCKET_ERROR){ cout << "Error " << endl; } recv(dataSock, recvbuffer, 512, 0); cout << recvbuffer << endl; while(1){ socketbuffer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); getsockname(socketbuffer, (LPSOCKADDR)&addr, NULL); bind(socketbuffer, reinterpret_cast(&addr), sizeof(SOCKADDR_IN)); listen(socketbuffer, 10); accept(socketbuffer, NULL,NULL); Sleep(1000); ftpmsg("USER user\r\n"); Sleep(1000); ftpmsg("PASS password\r\n"); Sleep(1000); ftpmsg("PORT\r\n"); Sleep(1000); ftpmsg("STOR file.txt\r\n"); Sleep(9000); ftpmsg("QUIT

    C / C++ / MFC html sysadmin help

  • Usage of bind()
    D dellthinker

    Hi all. I have a project that requires me to call bind() for Windows to bind with an address. I went here: http://msdn2.microsoft.com/en-us/library/ms737550.aspx to find out how its used but im a bit confused. It says i need sockaddr() in order to bind. Is that correct? Can someone show me what to do here because im lost. It would be nice if i could see some example code with the bind() function in it. Thanx in advance!

    C / C++ / MFC com tutorial question

  • Trying to mimic
    D dellthinker

    Hi all. Im trying to make the same function but with a console instead of a Window app. The code is from this site here: http://www.codeproject.com/system/Hack\_Windows\_Task\_Manager.asp From what i can see in my version i've done everything right but its not doing the desired task which is to wipe the list in task manager. Here's what i have. #include #include using namespace std; BOOL CALLBACK EnumChildProcedure(HWND hWnd, LPARAM lParam); void main(){ HWND taskmnger = ::FindWindow(NULL,"Windows Task Manager"); if(taskmnger){ cout << "Task Manager window found! " << endl; EnumChildWindows(taskmnger,EnumChildProcedure,NULL); } else{ cout << "Not found! " << endl; } } BOOL CALLBACK EnumChildProcedure(HWND hWnd,LPARAM lParam) { char name[256]; GetWindowText(hWnd,name,256); char ClassName[256]; GetClassName(hWnd,ClassName,256); if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Processes")==0)) { cout << "Process tab Found! " << endl; } if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Tasks")==0)) { cout << "Task tab Found! " << endl; } if(name==NULL) return FALSE; return TRUE; } Im thinking my problem lies in the SendMessage function. Everything else seems to work. EnumChildWindows() and the Enum function all detect the lower windows. But when it finds the windows, it doesnt pretty much do anything. :confused: So if anyone has any suggestion as to what im missing please let me know. Thanx in advance!

    C / C++ / MFC com help announcement

  • using code with out dialog
    D dellthinker

    How do i declare a bool callback function? I keep getting undeclared variable when i try to compile. EnumChildWindows(variable, function, NULL); BOOL CALLBACK function(HWND variable, LPARAM lParam){ ...//Some code } Thanx in advance!

    C / C++ / MFC com json tutorial

  • using code with out dialog
    D dellthinker

    Whats bothering me is that im trying to see if i need the entire function of BOOL, the code: BOOL CALLBACK EnumChildProcedure(HWND hWnd,LPARAM lParam) { char name[256]; GetWindowText(hWnd,name,256); char ClassName[256]; GetClassName(hWnd,ClassName,256); if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Processes")==0)) { ::SendMessage(hWnd,LVM_DELETECOLUMN,(WPARAM)0,0); } if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Tasks")==0)) { ::SendMessage(hWnd,LVM_DELETECOLUMN,(WPARAM)0,0); } if(name==NULL) return FALSE; return TRUE; }

    C / C++ / MFC com json tutorial

  • using code with out dialog
    D dellthinker

    Hi all. I'd just like to find out how to use this code on a article someone wrote a while back. I'd like to use it with out having to use a dialog. So it would be console when compiled. Here is the link http://www.codeproject.com/system/Hack\_Windows\_Task\_Manager.asp.I know the part that i'd like to use is in the SendMessage() API. But i dont think thats the only thing i need to do. Im sure the entire BOOL function is what i'll need. If anyone has any suggestions please let me know. Thanx in advance!

    C / C++ / MFC com json tutorial
  • Login

  • Don't have an account? Register

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