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
P

Patcher32

@Patcher32
About
Posts
21
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to get application focus?
    P Patcher32

    In Windows, you can do it using the WIN32API function SetForegroundWindow().

    C / C++ / MFC tutorial question

  • How to run an app in admin mode in Vista and 7
    P Patcher32

    No. Adding manifest is not the solution. I think its the process properties that one should look into.

    C / C++ / MFC tutorial

  • Windows 4, 5 and 6?
    P Patcher32

    Version 3 = Windows 3.1, Windows NT 3.0, Windows NT 3.5 Version 4 = Windows NT 4.0, Windows 95/98/98SE/Me Version 5 = Windows 2000, XP, 2003 Version 6 = Windows Vista, Windows 7, Windows 2008 Windows Vista was version 6.0 and Windows 7 is actually version 6.1 So there is no 7.0 yet.

    The Lounge announcement com sales question career

  • How to run an app in admin mode in Vista and 7
    P Patcher32

    I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.

    C / C++ / MFC tutorial

  • problem in printing factorial.............
    P Patcher32

    #include < stdio.h >

    void main()
    {
    int counter,fact=1,num=5;
    counter = num;
    clrscr();
    while(counter > 0)
    {
    fact = fact * counter;
    counter--;
    }
    printf("fact of %d is: %d",num,fact);

     getch();
    

    }

    C / C++ / MFC help learning

  • Programmatically deleting old files with a C program
    P Patcher32

    Since your program creates log files names based on date and time, you can parse file names for the time when they were created. That would be better method, than finding the file's last write time.

    C / C++ / MFC question

  • The SHCreateDirectoryEx function.
    P Patcher32

    #include <shlobj.h>
    int main(){
    SHCreateDirectoryEx(NULL,"c:\\jinx",NULL);
    return 0;
    }

    tested it with ms vc++ 2008. it works like charm :)

    C / C++ / MFC help debugging question

  • DeviceIoControl to lock drive is not working
    P Patcher32

    If I lock with (BYTE)TRUE : works If I unlock a locked device using (BYTE)FALSE : works If I try to unlock a device (without locking it first) using (BYTE)FALSE : gives error #22, The device does not recognize command I think this is expected behavior. Please guide me in right direction if I am doing it wrong.

    C / C++ / MFC help

  • DeviceIoControl to lock drive is not working
    P Patcher32

    Okay I finally got it to work. YAY! :) :) :) I made this change : pmr.PreventMediaRemoval = (BYTE)TRUE; in the original code I posted. But MSDN says the PreventMediaRemoval member is BOOLEAN? Thanks for confusing me MSDN! :mad::mad: The value has to be BYTE. So setting it to 1 locks drive from being ejected. Setting it to 0 unlocks the drive from ejecting.

    C / C++ / MFC help

  • DeviceIoControl to lock drive is not working
    P Patcher32

    Yes my DVD drive is F:. and handle returned by CreateFile is valid too. Thanks for replying

    C / C++ / MFC help

  • DeviceIoControl to lock drive is not working
    P Patcher32

    Yes hVolume is right value. GetLastError returns 0. GENERIC_READ already has FILE_READ_ATTRIBUTES Tried using 0 for File sharing but still DeviceIoControl gives error 87 parameter not correct Thanks for replying, I appreciate it.

    C / C++ / MFC help

  • DeviceIoControl to lock drive is not working
    P Patcher32

    Okay I am trying to lock CD drive (F: here) with the code shown. But DeviceIoControl is returning "error 87: Parameter not correct". Please someone help me. I cannot find out which parameter is incorrcet.

    #include <windows.h>
    #include <winioctl.h>
    #include <stdio.h>

    void ShowError(void); //function to display message from GetLastError()

    int main(){
    char szVolume[] = "\\\\.\\F:";
    HANDLE hVolume;
    DWORD dwBytes = 0;
    PREVENT_MEDIA_REMOVAL pmr;

    pmr.PreventMediaRemoval = TRUE;
    
    hVolume = CreateFile(szVolume,GENERIC\_READ|GENERIC\_WRITE,FILE\_SHARE\_READ|FILE\_SHARE\_WRITE,NULL,OPEN\_EXISTING,0,NULL);
    if(hVolume==INVALID\_HANDLE\_VALUE){
    	ShowError();
    	exit(1);
    }
    if(DeviceIoControl(hVolume,IOCTL\_STORAGE\_EJECTION\_CONTROL,(LPVOID)&pmr,(DWORD)sizeof(pmr),NULL,0,&dwBytes,NULL)==FALSE){
    	ShowError();
    }
    CloseHandle(hVolume);
    return 0;
    

    }

    C / C++ / MFC help

  • SetWindowsHookEx to modify GetSaveFileName
    P Patcher32

    I want to modify MSPaint's Save file dialog's default file type to JPG using SetWindowsHookEx In the hook function what message should I look for to get at GetSaveFileName?

    C / C++ / MFC question

  • question about copy a picture with c [modified]
    P Patcher32

    wb = open new binary file for writing, if file exists with same name, it will be truncated to 0 bytes ab = open new binary file for writing, if file exists with same name, new data would be written at end of file. This may lead to undesired results if file already exists. you should check if a file exists before opening it in wb mode :

    #include<stdlib.h>

    #include<stdio.h>
    #define MAX 1024

    int main(int argc,int **argv){

    FILE \*fsource,\*fdest;
    size\_t in;
    int buf\[MAX\];
        char c = 'n';
    fsource = fopen("F:\\\\a.jpg.rar","rb");
        //-----------Check if file exists---------
        fdest = fopen("D:\\\\a.jpg","r");
        if(fdest!=NULL){
           fclose(fdest);
           printf("Destination file already exists, do you want to overwrite?\\t");
           scanf("%c",&c);
           if(c!='Y' && c!='y'){
                fclose(fSource);
                return 1;
           }  
        }
        //---------------------------------------
    fdest = fopen("D:\\\\a.jpg","wb");
    if(fsource == NULL || fdest == NULL)
    	perror("open error");
    
    while((in = fread(buf,sizeof(int),MAX,fsource)) != 0){
    	fwrite(buf,sizeof(int),in,fdest);
    	fflush(fdest);
    }
    
    fclose(fsource);
    fclose(fdest);
    
    return EXIT\_SUCCESS;
    

    }

    C / C++ / MFC question help

  • How to convert real to binary
    P Patcher32

    Is it -16.735 or -16,735? -16.735 = -10000.1011110000101000111101011100001010001111010111 -16,735 = -100000101011111 The general procedure is to do integer and fraction part separately. For integer part N : 1. If N is not zero, divide N by 2 2. If remainder is 1 write down 1, if its 0 write down 0 3. N = N/2 - remainder. Go back to Step 1. Finally, write the 0 and 1 in reverse order. Example, N = 40 1. 40/2 = 20. Remainder = 0. Write 0 2. 20/2 = 10. Remainder = 0. Write 0 3. 10/2 = 5. Remainder = 0. Write 0 4. 5/2 = 2 + 1/2. Remainder = 1/2. Write 1 5. 2/2 = 1. Remainder = 0. Write 0 6. 1/2 = 0 + 1/2. Remainder = 1/2. Write 1 Threfore, 40 = 101000 For fraction part F, 1. If F is not zero, Multiply F by 2. 2. If result is greater than or equal to 1, write down 1. F = (F * 2) - 1 3. If result is not greater than 1, write down 1. F = (F * 2) 4. If F > 0 go back to step 1. Example, F = 0.25 1. 0.25 * 2 = 0.5. Write down 0 2. 0.5 * 2 = 1. Write down 1 Thus 0.25 = 0.01

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

  • Using GetOpenFileName on both Win98 and WinXP
    P Patcher32

    Yes. Its line # 34 in main.c When I remove if statement and just set lStructSize to one of the values, the code compiles perfectly.

    C / C++ / MFC json help question

  • Using GetOpenFileName on both Win98 and WinXP
    P Patcher32

    This is what Pelles C Compiler displays : Building MAIN.obj. C:\Code\Hasher\MAIN.C(34): fatal error: Internal error: get_rule(). *** Error code: 1 *** Done.

    C / C++ / MFC json help question

  • calculation error
    P Patcher32

    None of the values have been initialized and it always causes problem as the programs works on a random garbage value. 1. endbal is not initialized. Either set it to 0 or some other positive value at the start of your program. 2. finbal must be set to 0 at the start of main() function. You can initialize these at the time of declaration : float endbal = 0, finbal = 0; Also the statement finbal = endbal + outdep - withdraw; is wrong. You have already added deposit amount and subtracted withdrawn amount in the variable finbal. So all you need is endbal = endbal + finbal. Finally, you are displaying the wrong value. You should display endbal in the last printf statement. I hope this helps you.

    modified on Wednesday, October 14, 2009 6:59 PM

    C / C++ / MFC help question

  • Using GetOpenFileName on both Win98 and WinXP
    P Patcher32

    GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :

    OPENFILENAME ofn;
    if(win98()==FALSE)
    ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
    else
    ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/ME

    Ofcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you

    C / C++ / MFC json help question

  • When to execute hashing function in Win32 app
    P Patcher32

    Thank you and others who took time to respond. Its working now :-)

    C / C++ / MFC cryptography help 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