Posted: Mon Jul 09, 2007 10:02 am
download link seems broken 

http://www.purebasic.com
https://www.purebasic.fr/english/
No problem, the link goes to purearea.net and than to me webspace:Flype wrote:download link seems broken
Code: Select all
EnableExplicit
Define.l objShell
Define.l objFwMgr
Define.b bResult
Define.l oProfile
dhToggleExceptions(#True)
objShell = dhCreateObject("Shell.Application")
If objShell
dhGetValue("%b", @bResult, objShell, "IsServiceRunning(%T)", @"SharedAccess")
If bResult
objFwMgr = dhCreateObject("HNetCfg.FwMgr")
If objFwMgr
dhGetValue("%o", @oProfile, objFwMgr, ".LocalPolicy.CurrentProfile")
If oProfile
dhGetValue("%b", @bResult, oProfile, ".FirewallEnabled")
If bResult
If MessageRequester("Information", "Firewall is enable." + #LF$ + "Do you want to disable the Firewall ?", #MB_OKCANCEL) = #IDOK
dhPutValue(oProfile, ".FirewallEnabled = %b", #False)
EndIf
Else
If MessageRequester("Information", "Firewall is disabled." + #LF$ + "Do you want to enable the Firewall ?", #MB_OKCANCEL) = #IDOK
dhPutValue(oProfile, ".FirewallEnabled = %b", #True)
EndIf
EndIf
EndIf
dhReleaseObject(objFwMgr)
EndIf
Else
dhCallMethod(objShell, ".ServiceStart(%T, %b)", @"SharedAccess", #True)
EndIf
dhReleaseObject(objShell)
EndIf
Code: Select all
Procedure EnableFirewall(bool.b)
Protected objShell.l, objFwMgr.l, bResult.b
objShell = dhCreateObject("Shell.Application")
If objShell
dhGetValue("%b", @bResult, objShell, "IsServiceRunning(%T)", @"SharedAccess")
If bResult
objFwMgr = dhCreateObject("HNetCfg.FwMgr")
If objFwMgr
dhPutValue(objFwMgr, ".LocalPolicy.CurrentProfile.FirewallEnabled = %b", bool)
dhReleaseObject(objFwMgr)
EndIf
EndIf
dhReleaseObject(objShell)
EndIf
EndProcedure
Procedure.b IsFirewallEnabled()
Protected objShell.l, objFwMgr.l, bResult.b
objShell = dhCreateObject("Shell.Application")
If objShell
dhGetValue("%b", @bResult, objShell, "IsServiceRunning(%T)", @"SharedAccess")
If bResult
objFwMgr = dhCreateObject("HNetCfg.FwMgr")
If objFwMgr
dhGetValue("%b", @bResult, objFwMgr, ".LocalPolicy.CurrentProfile.FirewallEnabled")
dhReleaseObject(objFwMgr)
EndIf
EndIf
dhReleaseObject(objShell)
EndIf
ProcedureReturn bResult
EndProcedure
; Active/Désactive le Firewall
#ComTrue = -1
EnableFirewall(#ComTrue - IsFirewallEnabled())
Code: Select all
#MQ_RECEIVE_ACCESS = 1
#MQ_SEND_ACCESS = 2
#MQ_PEEK_ACCESS = 32
#MQ_DENY_NONE = 0
#MQ_DENY_RECEIVE_SHARE = 1
#MQ_NO_TRANSACTION = 0
#MQ_MTS_TRANSACTION = 1
#MQ_XA_TRANSACTION = 2
#MQ_SINGLE_MESSAGE = 3
#MQ_ERROR_QUEUE_NOT_EXIST = -1072824317
#MQMSG_ACKNOWLEDGMENT_FULL_REACH_QUEUE = 5
#MQMSG_ACKNOWLEDGMENT_FULL_RECEIVE = 14
#DEFAULT_MAX_TIME_TO_REACH_QUEUE = 20
qi = dhCreateObject("MSMQ.MSMQQueueInfo.1")
dhPutValue(qi, "PathName=%s", @".\private$\TestQueue")
;Send a message
dhGetValue("%o", @myq, qi, "Open(%d,%d)", #MQ_SEND_ACCESS, #MQ_DENY_NONE)
If myq
Debug "Opened private$\TestQueue for sending"
out_msg = dhCreateObject("MSMQ.MSMQMessage.1")
body.s = "Hello MSMQ!"
label.s = "TestMessage"
dhPutValue(out_msg, "Label=%s", @label)
dhPutValue(out_msg, "Body=%s", @body)
Debug " sending message 'TestMessage' with content='Hello MSMQ!'"
dhCallMethod(out_msg, "Send(%o)", myq)
dhReleaseObject(out_msg)
dhCallMethod(myq, "Close()")
Debug "Queue closed"
dhReleaseObject(myq)
EndIf
Debug ""
;Receive the message
dhGetValue("%o", @myq, qi, "Open(%d,%d)", #MQ_RECEIVE_ACCESS, #MQ_DENY_NONE)
If myq
Debug "Opened private$\TestQueue for receiving"
dhGetValue("%o", @in_msg, myq, "Receive()")
If msg
dhGetValue("%s", @message, in_msg, "Body")
Debug " Message received: '" + PeekS(message) + "'"
dhReleaseObject(in_msg)
EndIf
dhCallMethod(myq, "Close()")
Debug "Queue closed"
dhReleaseObject(myq)
EndIf
dhReleaseObject(qi)
Code: Select all
set myUser = GetObject("LDAP://cn=UserNameMe,cbn=users dc=domain,dc=net)
I have no idea what this means? Does it mean put a zero in the variable used to point to the object or something?DispHelper .chm file wrote:"It is recommended to put the variable afterwards on 0"