Results 1 to 15 of 15

Thread: SCAR/SIMBA API CALL (ChangeDisplaySettings)

  1. #1
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default SCAR/SIMBA API CALL (ChangeDisplaySettings)

    using SCAR or simba how would this properly work?

    SCAR Code:
    type DEVMODE = record
      dmBitsPerPel,dmPelsWidth,dmPelsHeight //i am soo lost i am going to leave this

    function changedisplay(DevMode:unknown; dwflags:unknown):unknown; external [email]ChangeDisplaySettings@user32.dll[/email] stdcall' ;

    also what else would i need? the device name and such?
    would the DEVMODE and DWFLAGS need to be a record of some sort or a function?
    whomever has experience in windows let me know

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by wantonman View Post
    using SCAR or simba how would this properly work?

    SCAR Code:
    type DEVMODE = record
      dmBitsPerPel,dmPelsWidth,dmPelsHeight //i am soo lost i am going to leave this

    function changedisplay(DevMode:unknown; dwflags:unknown):unknown; external [email]ChangeDisplaySettings@user32.dll[/email] stdcall' ;

    also what else would i need? the device name and such?
    would the DEVMODE and DWFLAGS need to be a record of some sort or a function?
    whomever has experience in windows let me know


    Well.. I'd save you the lecture by saying it's probably not a good idea to choose Simba for things suited for C/WinAPI.. I doubt Pascal/Lape/Simba is suited well for WinAPI but meh.. Here you go:


    Simba Code:
    const
      CDS_TEST = $00000002;
      CDS_FULLSCREEN = $00000004;
      ENUM_CURRENT_SETTINGS = -1;
      DISP_CHANGE_SUCCESSFUL = 0;
      DISP_CHANGE_RESTART = 1;
      DM_PELSWIDTH = $00080000;
      DM_PELSHEIGHT = $00100000;
      DM_DISPLAYFREQUENCY = $00400000;
      CDS_UPDATEREGISTRY = $00000001;
      DISPLAY_DEVICE_PRIMARY_DEVICE = $00000004;

    type DISPLAY_DEVICE = record
      cb: dWord;
      DeviceName: array[0..31] of char;
      DeviceString: array[0..127] of char;
      StateFlags: dWord;
      DeviceID: array[0..127] of char;
      DeviceKey: array[0..127] of char;
    end;

    type DEVMODE = record
      dmDeviceName: array [0..31] of char;
      dmSpecVersion: Word;
      dmDriverVersion: Word;
      dmSize: Word;
      dmDriverExtra: Word;
      dmFields: dWord;
      dmOrientation: ShortInt;
      dmPaperSie: ShortInt;
      dmPaperLength: ShortInt;
      dmPaperWidth: ShortInt;
      dmScale: ShortInt;
      dmCopies: ShortInt;
      dmDefaultSource: ShortInt;
      dmPrintQuality: ShortInt;
      dmColor: ShortInt;
      dmDuplex: ShortInt;
      dmYResolution: ShortInt;
      dmTTOption: ShortInt;
      dmCollate: ShortInt;
      dmFormName: array [0..31] of char;
      dmLogPixels: Word;
      dmBitsPerPel: UInt16;
      dmPelsWidth: dWord;
      dmPelsHeight: dWord;
      dmDisplayFlags: dWord;
      dmDisplayFrequency: dWord;

      dmICMMethod: dWord;
      dmICMIntent: dWord;
      dmMediaType: dWord;
      dmDitherType: dWord;
      dmReserved1: dWord;
      dmReserved2: dWord;
    end;

    Function ChangeDisplaySettings(DEVMODE: ^DevMode; dwflags: DWORD): LongInt; external 'ChangeDisplaySettings@user32.dll stdcall';
    Function EnumDisplayDevices(const lpDevice: ^String; iDevNum: DWORD; lpDisplayDevice: ^DISPLAY_DEVICE; dwFlags: DWORD): Boolean; external 'EnumDisplayDevices@user32.dll stdcall';


    Function GetPrimaryDevice: DISPLAY_DEVICE;
    var
      index: Integer = 0;
      dd: DISPLAY_DEVICE;
    begin
      dd.cb = sizeof(DISPLAY_DEVICE);

      while (EnumDisplayDevices(nil, index, @dd, 0)) do
      begin
        if (dd.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE) then
        begin
          Result := dd;
          exit;
        end;
        Inc(Index);
      end;

      Result := dd;
    end;

    Function SetDisplayResolution(PelsWidth, PelsHeight: LongInt): Boolean;
    var
      dm: DEVMODE;
      dd: DISPLAY_DEVICE;
    Begin
        dd = GetPrimaryDevice;
        dm.dmSize = sizeof(DEVMODE);

        if (!EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, @dm)) then
        begin
          Result := False;
          Exit;
        end;

        dm.dmPelsWidth = PelsWidth;
        dm.dmPelsHeight = PelsHeight;
        dm.dmFields = (DM_PELSWIDTH or DM_PELSHEIGHT);
        if (ChangeDisplaySettings(@dm, CDS_TEST) <> DISP_CHANGE_SUCCESSFUL) then
        begin
          Result := False;
          Exit;
        end;

        Result := (ChangeDisplaySettings(@dm, 0) = DISP_CHANGE_SUCCESSFUL);
    End;

    begin
      SetDisplayResolution(800, 600);
    end.
    Last edited by Brandon; 10-27-2013 at 03:13 AM.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    thats alot of info good to study, hey dont use BASIC for win api except for the systembeep function residing in kernel32.dll aia afasgd i navigate all the way to hklocalmacine\currentcontrolset\monitor1 and enter xny resolution then restart my computer everytime cuz i use different monitors for stuff. yehh i can create a hive file but that still would require a restart for the changes 2 take effect. my dll knowledge is okay buy am not certain. yes there was anotherway by actually creating a new mode in the list all modes interface but tis was with winmodelines and am not an expert at that. manually would ber absolute.

    hence nerd dubstep...
    SCAR Code:
    var i,i2,x:integer;
    function F0(C1, C2: integer): boolean; external 'Beep@kernel32.dll stdcall' ;
    Begin
    f0(700,1000)
    f0(950,1000)
    f0(600,1000)
    f0(700,1000)
    f0(600,1000)
    f0(40,1000)
    f0(100,1000)
    f0(40,1000)
    f0(100,1000)
    f0(40,1000)
    for i:=12000 downto 2000 do begin
    i:=i-44
    f0(i,1)end;
    for i:=0 to 7 do begin
    f0(100,99)f0(200,99)f0(800,99)end;
    for i:=0 to 7 do begin
    f0(100,99)f0(200,99)f0(1600,99)end;
    for i:=0 to 7 do begin
    f0(100,99)f0(200,99)f0(700,99)end;
    for i:=0 to 7 do begin
    f0(100,99)f0(200,99)f0(1400,99)end;
    for i:=0 to 7 do begin
    f0(100,99)f0(200,99)f0(600,99)end;
    sleep(99)
    for i:=0 to 3 do begin
    f0(100,9)f0(600,9)end;
    sleep(99)
    for i:=0 to 3 do begin
    f0(100,9)f0(700,9)end;
    sleep(99)
    for i:=0 to 3 do begin
    f0(100,9)f0(800,9)end;
    sleep(99)
    f0(40,4000)
    for i2:=0 to 3 do begin
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(800,9)end;
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(1600,9)end;
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(700,9)end;
    for i:=0 to 5 do begin
    f0(100,99)f0(200,9)f0(1400,9)end;
    for i:=0 to 7 do begin
    f0(100,9)f0(200,9)f0(600,9)end;
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(700,9)end;
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(800,9)end;
    for i:=0 to 5 do begin
    f0(100,9)f0(200,9)f0(1600,9)end;
    end;
    for i:=0 to 3 do begin
    f0(40,99)sleep(400)end;
    End.
    windows

  4. #4
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    i tryed it but i get unknown type dword??? is this supported? are there any workarounds?

  5. #5
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    type devmode = record
    dm_BitsPerPel:integer;
    dm_PelsWidth:integer;
    dm_PelsHeight:integer;
    dm_DisplayFlags:integer;
    dm_DisplayFrequency:integer;
    dm_Position:integer;
    end;
    var
    dm:devmode;
    Function f0(devmode:devmode;dwflags:integer): LongInt; external 'ChangeDisplaySettings@user32.dll stdcall';
    begin
    dm.dm_BitsPerPel:=32
    dm.dm_PelsWidth:=640
    dm.dm_PelsHeight:=480
    //dm.dmDisplayFlags:=
    dm.dm_DisplayFrequency:=60
    //dm.dmPosition:=
    f0(dm,0)
    end.



    this
    is
    all
    i
    have

  6. #6
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by m3gaman3g3nd View Post
    i tryed it but i get unknown type dword??? is this supported? are there any workarounds?
    A DWORD is equivalent to Uint32. You'll need to enable API calls in Simba's settings. Is there a reason you want this?
    I am Ggzz..
    Hackintosher

  7. #7
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    well if i can get this working then i can make another version an any other compiler (C, Assembler) and have a quick way to change unsupported resolutions in windows instead of restarting... i am around six feet away from my monitor and sometimes a larger resolution works well with this distance... its for my work environment. (ViewSonic E790B)
    yeh simba/scar works for me for now to explore windows dlls anyways, its already on my computer and i am familliar with it.

  8. #8
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by m3gaman3g3nd View Post
    well if i can get this working then i can make another version an any other compiler (C, Assembler) and have a quick way to change unsupported resolutions in windows instead of restarting... i am around six feet away from my monitor and sometimes a larger resolution works well with this distance... its for my work environment. (ViewSonic E790B)
    yeh simba/scar works for me for now to explore windows dlls anyways, its already on my computer and i am familliar with it.


    Set your interpreter to PascalScript.. Set your settings to AllowSysCalls (Edit C:/Simba/Settings.xml and set AllowSysCalls to true).
    It seems as though PS doesn't have "sizeof".. Also difficult since it has no pointers..

    Run this:

    Simba Code:
    const
      CDS_TEST = $00000002;
      CDS_FULLSCREEN = $00000004;
      ENUM_CURRENT_SETTINGS = -1;
      DISP_CHANGE_SUCCESSFUL = 0;
      DISP_CHANGE_RESTART = 1;
      DM_PELSWIDTH = $00080000;
      DM_PELSHEIGHT = $00100000;
      DM_DISPLAYFREQUENCY = $00400000;
      CDS_UPDATEREGISTRY = $00000001;
      DISPLAY_DEVICE_PRIMARY_DEVICE = $00000004;

    type DISPLAY_DEVICE = record
      cb: LongWord;
      DeviceName: array[0..31] of char;
      DeviceString: array[0..127] of char;
      StateFlags: LongWord;
      DeviceID: array[0..127] of char;
      DeviceKey: array[0..127] of char;
    end;

    type DEVMODE = record
      dmDeviceName: array [0..32] of char;
      dmSpecVersion: WORD;
      dmDriverVersion: WORD;
      dmSize: WORD;
      dmDriverExtra: WORD;
      dmFields: LongWord;
      dmOrientation: ShortInt;
      dmPaperSie: WORD;
      dmPaperLength: WORD;
      dmPaperWidth: WORD;
      dmScale: WORD;
      dmCopies: WORD;
      dmDefaultSource: WORD;
      dmPrintQuality: WORD;
      dmColor: WORD;
      dmDuplex: WORD;
      dmYResolution: WORD;
      dmTTOption: WORD;
      dmCollate: WORD;
      dmFormName: array [0..31] of char;
      dmLogPixels: WORD;
      dmBitsPerPel: LongWord;
      dmPelsWidth: LongWord;
      dmPelsHeight: LongWord;
      dmDisplayFlags: LongWord;
      dmDisplayFrequency: LongWord;
      dmICMMethod: LongWord;
      dmICMIntent: LongWord;
      dmMediaType: LongWord;
      dmDitherType: LongWord;
      dmReserved1: LongWord;
      dmReserved2: LongWord;
    end;

    Function ChangeDisplaySettings(var mode: DevMode; dwflags: LongWord): LongInt; external 'ChangeDisplaySettingsA@user32.dll stdcall';
    Function EnumDisplayDevices(const lpDevice: array of char; iDevNum: LongWord; var lpDisplayDevice: DISPLAY_DEVICE; dwFlags: LongWord): Boolean; external 'EnumDisplayDevicesA@user32.dll stdcall';
    Function EnumDisplaySettings(const lpszDeviceName: array of char; iModeNum: LongWord; var lpDevMode: DEVMODE): Boolean; external 'EnumDisplaySettingsA@user32.dll stdcall';

    Function ChaToString(arr: array of char): String;
    var
      I: Integer;
    Begin
      SetLength(Result, Length(Arr));
      For I := 1 To Length(Arr) Do
        Result[I] := Arr[I - 1];

      Result := Trim(Result);
    End;

    Procedure ListDisplayDevices;
    var
      Index: Integer;
      dd: DISPLAY_DEVICE;
      Str: String;
    begin
      Index := 0;
      dd.cb := 424;

      while (EnumDisplayDevices([], Index, dd, 0)) do
      begin
        if ((dd.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE) <> 0) then
          Str := '*';
        Str := Str + ChaToString(dd.DeviceName) + ', ' + ChaToString(dd.DeviceString);
        writeln(Str);
        Str := '';
        Inc(Index);
      end;
    end;

    Procedure ListDisplaySettings(Index: Integer);
    var
      dm: DEVMODE;
      dd, monitor: DISPLAY_DEVICE;
    begin
        dd.cb := 424;//sizeof(DISPLAY_DEVICE);
        monitor.cb := 424;
        dm.dmSize := 156;//sizeof(DEVMODE);

        if (Not EnumDisplayDevices([], index, dd, 0)) then
        begin
          writeln('EnumDisplayDevices failed');
          Exit;
        end;

        if (Not EnumDisplayDevices(dd.DeviceName, index, monitor, 0)) then
        begin
          writeln('EnumDisplayDevices failed');
          Exit;
        end;

        if (Not EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, dm)) then
        begin
          writeln('EnumDisplaySettings failed');
          Exit;
        end;

        writeln('Device name: ' + ChaToString(dd.DeviceName));
        writeln('Monitor name: ' + ChaToString(monitor.DeviceID));
        writeln('Refresh rate in hertz: ' + ToStr(dm.dmDisplayFrequency));
        writeln('Colour depth: ' + ToStr(dm.dmBitsPerPel));
        writeln('Screen resolution: ' + ToStr(dm.dmPelsWidth) + ' ' + ToStr(dm.dmPelsHeight));
    end;

    Function GetPrimaryDevice: DISPLAY_DEVICE;
    var
      Index: Integer;
      dd: DISPLAY_DEVICE;
    begin
      Index := 0;
      dd.cb := 424;

      while (EnumDisplayDevices([], Index, dd, 0)) do
      begin
        if ((dd.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE) <> 0) then
        begin
          Result := dd;
          Exit;
        end;
        Inc(Index);
      end;

      Result := dd;
    end;

    Function SetDisplayResolution(PelsWidth, PelsHeight: LongInt): Boolean;
    var
      dm: DEVMODE;
      dd: DISPLAY_DEVICE;
    Begin
      dd := GetPrimaryDevice();
      dm.dmSize := 156;

      if (Not EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, dm)) then
      begin
        writeln('EnumDisplaySettings failed');
        Result := False;
        Exit;
      end;

      dm.dmPelsWidth := PelsWidth;
      dm.dmPelsHeight := PelsHeight;
      dm.dmFields := (DM_PELSWIDTH or DM_PELSHEIGHT);

      if (ChangeDisplaySettings(dm, CDS_TEST) <> DISP_CHANGE_SUCCESSFUL) then
      begin
        writeln('Illegal graphics mode');
        Result := False;
        Exit;
      end;

      Result := (ChangeDisplaySettings(dm, 0) = DISP_CHANGE_SUCCESSFUL);
    End;

    begin
      ListDisplayDevices();
      writeln('');
      ListDisplaySettings(0);
      writeln(SetDisplayResolution(800, 600));
    end.

    It prints:

    Progress Report:
    Allowing API/SysCalls.
    Compiled successfully in 16 ms.
    *\\.\DISPLAY1, Intel(R) HD Graphics 4000
    \\.\DISPLAY2, Intel(R) HD Graphics 4000
    \\.\DISPLAY3, Intel(R) HD Graphics 4000
    \\.\DISPLAY4, NVIDIA GeForce GT 635M
    
    Device name: \\.\DISPLAY1
    Monitor name: MONITOR\CMO1590\{4d36e96e-e325-11ce-bfc1-08002be10318}\0001
    Refresh rate in hertz: 60
    Colour depth: 32
    Screen resolution: 1366 768
    True
    Successfully executed.



    It seems to work. Well.. it does something...

    It should at LEAST make your display flicker.
    Last edited by Brandon; 02-19-2014 at 11:55 PM.
    I am Ggzz..
    Hackintosher

  9. #9
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    can this be done with mswindows debug utility? you can assemble code directly here. if you type debug at command you get the program ip then you can enter a for assemble and debug returns 1465:0100
    can you assemble with shell32.dll functions?

  10. #10
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by m3gaman3g3nd View Post
    can this be done with mswindows debug utility? you can assemble code directly here. if you type debug at command you get the program ip then you can enter a for assemble and debug returns 1465:0100
    can you assemble with shell32.dll functions?

    Not sure what I just read.. What are you trying to say :S? Typing debug in cmd doesn't do anything on my system. Programs do not have IP's either. Assembling with shell32? What? The only assemblers I've ever used are:

    MASM, FASM, NASM, TASM, MIPS, and a couple others..

    I've used more disassemblers than I can count. Again, I don't mean any harm but.. I'm not exactly sure what it is you are trying to accomplish but the code I gave you should indeed work.

    I highly doubt you can assemble anything using Shell32.dll. Shell32 only has these functions: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    Last edited by Brandon; 02-20-2014 at 02:14 AM.
    I am Ggzz..
    Hackintosher

  11. #11
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    it says in the msdn the only members needed are
    dmBitsPerPel
    dmPelsWidth
    dmPelsHeight
    dmDisplayFlags
    dmDisplayFrequency
    dmPosition

    your code absolutely does everything required for the ChangeDisplaySettings funtion

    when you call GetPrimaryDevice in your code it gets the primary display device and sets the dmDeviceName to what has theEnumDisplayDevices function had found.

    it all is flawless, my screen flickers and it spits out information
    *\\.\DISPLAY1 , ATI MOBILITY RADEON Xpress 200 Series
    \\.\DISPLAY2 , ATI MOBILITY RADEON Xpress 200 Series
    \\.\DISPLAYV1 , NetMeeting driver
    \\.\DISPLAYV2 , RDPDD Chained DD

    Device name: \\.\DISPLAY1
    Monitor name: Monitor\PNP09FE\{4D36E96E-E325-11CE-BFC1-08002BE10318}\0000
    Refresh rate in hertz: 60
    Colour depth: 8
    Screen resolution: 640 480



    it should stick to the settings unless theres another thing, it looks all filled completely, im boggled.

  12. #12
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by wantonman View Post
    it should stick to the settings unless theres another thing, it looks all filled completely, im boggled.
    It's a Simba problem. Guaranteed. The exact same code works in C. Simba is printing the info fine as well. It should also be changing the resolution :l. Too bad lape can't be used for Sys-API calls..
    I am Ggzz..
    Hackintosher

  13. #13
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    Ive been meaning to get this post about free pascal and using your code here in a function "result" seems to not work and it causes an error on compilation but its okay


    This is for free pascal compiler
    Simba Code:
    const
      CDS_TEST = $00000002;
      CDS_FULLSCREEN = $00000004;
      ENUM_CURRENT_SETTINGS = -1;
      DISP_CHANGE_SUCCESSFUL = 0;
      DISP_CHANGE_RESTART = 1;
      DM_PELSWIDTH = $00080000;
      DM_PELSHEIGHT = $00100000;
      DM_DISPLAYFREQUENCY = $00400000;
      CDS_UPDATEREGISTRY = $00000001;
      DISPLAY_DEVICE_PRIMARY_DEVICE = $00000004;

    type DISPLAY_DEVICE = record
      cb: LongWord;
      DeviceName: array[0..31] of char;
      DeviceString: array[0..127] of char;
      StateFlags: LongWord;
      DeviceID: array[0..127] of char;
      DeviceKey: array[0..127] of char;
    end;

    type DEVMODE = record
      dmDeviceName: array [0..32] of char;
      dmSpecVersion: WORD;
      dmDriverVersion: WORD;
      dmSize: WORD;
      dmDriverExtra: WORD;
      dmFields: LongWord;
      dmOrientation: ShortInt;
      dmPaperSie: WORD;
      dmPaperLength: WORD;
      dmPaperWidth: WORD;
      dmScale: WORD;
      dmCopies: WORD;
      dmDefaultSource: WORD;
      dmPrintQuality: WORD;
      dmColor: WORD;
      dmDuplex: WORD;
      dmYResolution: WORD;
      dmTTOption: WORD;
      dmCollate: WORD;
      dmFormName: array [0..31] of char;
      dmLogPixels: WORD;
      dmBitsPerPel: LongWord;
      dmPelsWidth: LongWord;
      dmPelsHeight: LongWord;
      dmDisplayFlags: LongWord;
      dmDisplayFrequency: LongWord;
      dmICMMethod: LongWord;
      dmICMIntent: LongWord;
      dmMediaType: LongWord;
      dmDitherType: LongWord;
      dmReserved1: LongWord;
      dmReserved2: LongWord;
    end;

    Function ChangeDisplaySettingsA(var mode: DevMode; dwflags: LongWord):LongInt; stdcall; external 'user32.dll';

    var
      dm: DEVMODE;

    begin
      ChangeDisplaySettingsA(dm, CDS_TEST)
    end.

    this compiles but the program doesnt do much...
    i know ive not put in other functions but free pascal uses stdcall; before the external and there is no @ in the dll path which is okay.

  14. #14
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by wantonman View Post
    this compiles but the program doesnt do much...
    Translate this to pascal and it will 100% work:

    C Code:
    bool SetDefaultDisplaySettings()
    {
        return ChangeDisplaySettings(NULL, 0) == DISP_CHANGE_SUCCESSFUL;
    }

    bool SetDisplayResolution(int width, int height)
    {
        DISPLAY_DEVICE dd = GetPrimaryDisplayDevice();
        DEVMODE dm = { 0 };
        dm.dmSize = sizeof(DEVMODE);

        if (EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm))
        {
            dm.dmPelsWidth = width;
            dm.dmPelsHeight = height;
            dm.dmFields = (DM_PELSWIDTH | DM_PELSHEIGHT);

            if (ChangeDisplaySettings(&dm, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
            {
                return false;
            }

            return (ChangeDisplaySettings(&dm, 0) == DISP_CHANGE_SUCCESSFUL);
        }

        return false;
    }


    I would translate it but I'm watching a movie.. maybe after I'll translate it. This code is from the "Riddler" library I wrote somewhere around here.. Not sure where the thread is but it's somewhere on these forums.
    I am Ggzz..
    Hackintosher

  15. #15
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Theres this program called reschanger.exe

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •