Guest - Ricardo - Postado Janeiro 26, 2005 Denunciar Share Postado Janeiro 26, 2005 Alguém sabe com fazer para abrir um arquivo cpl pelo vb?Já tentei shell e shellexecute e não consegui. Com o shellexecute nada acontece.Quero abrir o desk.cpl (C:/windows/system), para que meu usuário modifique a resolução do micro.Vlw Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 diegoinfo Postado Janeiro 27, 2005 Denunciar Share Postado Janeiro 27, 2005 Achei este código, e testei. Ele muda direto a resolução.Declaration:Option Explicit Private Const EWX_REBOOT = 2 Private Const CCDEVICENAME = 32 Private Const CCFORMNAME = 32 Private Const DM_BITSPERPEL = &H40000 Private Const DM_PELSWIDTH = &H80000 Private Const DM_PELSHEIGHT = &H100000 Private Const CDS_UPDATEREGISTRY = &H1 Private Const CDS_TEST = &H4 Private Const DISP_CHANGE_SUCCESSFUL = 0 Private Const DISP_CHANGE_RESTART = 1 Private Type typDevMODE dmDeviceName As String * CCDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Private Declare Function EnumDisplaySettings Lib _ "user32" Alias "EnumDisplaySettingsA" _ (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, _ lptypDevMode As Any) As Boolean Private Declare Function ChangeDisplaySettings Lib _ "user32" Alias "ChangeDisplaySettingsA" (lptypDevMode As Any, _ ByVal dwFlags As Long) As Long Private Declare Function ExitWindowsEx Lib _ "user32" (ByVal uFlags As Long, _ ByVal dwReserved As Long) As Long Código: Public Function ChangeDisplayResolution(NewWidth As Long, _ NewHeight As Long) As Boolean 'Usage: ChangeDisplayResolution 800, 600 'Returns: True if succesful, false otherwise 'Comments: Problems have been reported using this code for 'resolutions higher than 1024 X 768. We recommend not using this 'snippet to go above this limit. Dim typDM As typDevMODE Dim lRet As Long Dim iResp As Integer 'typDM = pointer to info about current 'display settings lRet = EnumDisplaySettings(0, 0, typDM) If lRet = 0 Then Exit Function ' Set the new <B style="color:black;background-color:#A0FFFF">resolution</B>. With typDM .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT .dmPelsWidth = NewWidth .dmPelsHeight = NewHeight End With 'Do the update -- Pass update structure to 'ChangeDisplaySettings API function lRet = ChangeDisplaySettings(typDM, CDS_UPDATEREGISTRY) Select Case lRet Case DISP_CHANGE_RESTART iResp = MsgBox _ ("You must restart your computer to apply these changes." & _ vbCrLf & vbCrLf & "Restart now?", _ vbYesNo + vbInformation, "Screen <B style="color:black;background-color:#A0FFFF">Resolution</B> Changed") If iResp = vbYes Then ChangeDisplayResolution = True Reboot End If Case DISP_CHANGE_SUCCESSFUL ChangeDisplayResolution = True Case Else ChangeDisplayResolution = False End Select End Function Private Sub Reboot() Dim lRet As Long lRet = ExitWindowsEx(EWX_REBOOT, 0) End Sub você pode tirar a parte do reboot, nem precisa reiniciar a máquina.falou Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
Guest - Ricardo -
Alguém sabe com fazer para abrir um arquivo cpl pelo vb?
Já tentei shell e shellexecute e não consegui.
Com o shellexecute nada acontece.
Quero abrir o desk.cpl (C:/windows/system), para que meu usuário modifique a resolução do micro.
Vlw
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.