|
[quote]
What I have found is a code in VB language that works perfectly.
[/quote]
If you were to point us at the VB code we could probably translate it. Probably it works by replying to the WM_POWER message where wParam is APM_QUERYSUSPEND or something?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hi! It`s a very good luck, coz I got the code from your site (www.merrioncomputing.com)! Nice code guys!
Here`s the code:
'IN A MODULE<br />
Option Explicit<br />
<br />
Public oldProcAddress As Long<br />
<br />
Public Enum enPowerBroadcastType<br />
PBT_APMQUERYSUSPEND = &H0<br />
PBT_APMQUERYSTANDBY = &H1<br />
PBT_APMQUERYSUSPENDFAILED = &H2<br />
PBT_APMQUERYSTANDBYFAILED = &H3<br />
PBT_APMSUSPEND = &H4<br />
PBT_APMSTANDBY = &H5<br />
PBT_APMRESUMECRITICAL = &H6<br />
PBT_APMRESUMESUSPEND = &H7<br />
PBT_APMRESUMESTANDBY = &H8<br />
End Enum<br />
<br />
Public Const BROADCAST_QUERY_DENY = &H424D5144<br />
Public Const WM_POWER = &H48<br />
Public Const WM_POWERBROADCAST = &H218<br />
Public Const PWR_SUSPENDREQUEST = 1<br />
Public Const GWL_WNDPROC = (-4)<br />
Public Const PWR_FAIL = (-1)<br />
<br />
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<br />
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br />
<br />
'\\ In a .BAS file:<br />
'\\ --[VB_WindowProc]--------------------------------------------<br />
'\\ 'typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM,<br />
'\\ LPARAM);<br />
'\\ Parameters:<br />
'\\ hwnd - window handle receiving message<br />
'\\ wMsg - The window message (WM_..etc.)<br />
'\\ wParam - First message parameter<br />
'\\ lParam - Second message parameter<br />
'\\ Note:<br />
'\\ When subclassing a window proc using this, set the<br />
'\\ eventhandlerhOldWndProc property to the window's previous<br />
'\\ window proc address.<br />
'\\ -------------------------------------------------------------'\\ You have a royalty free right to use, reproduce, modify,<br />
'\\ publish and mess with this code<br />
'\\ I'd like you to visit http://www.merrioncomputing.com for<br />
'\\ updates, but won't force you<br />
'\\ ----------------------------------------------------------<br />
<br />
Public Function VB_WindowProc(ByVal hWnd As Long, ByVal wMsg As _<br />
Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br />
<br />
On Local Error Resume Next<br />
Dim lRet As Long<br />
<br />
<br />
'\\ If its a power suspending broadcast, kill it...<br />
If wMsg = WM_POWER And wParam = PWR_SUSPENDREQUEST Then<br />
'\\ This is the message in Windows NT/2000<br />
VB_WindowProc = PWR_FAIL<br />
ElseIf wMsg = WM_POWERBROADCAST And wParam = _<br />
PBT_APMQUERYSUSPEND Then<br />
VB_WindowProc = BROADCAST_QUERY_DENY<br />
Else<br />
VB_WindowProc = CallWindowProc(oldProcAddress, hWnd, wMsg, _<br />
wParam, lParam)<br />
End If<br />
<br />
End Function<br />
<br />
'\\ IN OUR APP's MAIN FORM:<br />
Private Sub Form_Load()<br />
<br />
oldProcAddress = SetWindowLong(Me.hWnd, GWL_WNDPROC, _<br />
AddressOf VB_WindowProc)<br />
<br />
End Sub<br />
<br />
Private Sub Form_Unload(Cancel As Integer)<br />
<br />
Call SetWindowLong(Me.hWnd, GWL_WNDPROC, oldProcAddress)<br />
<br />
End Sub
That works fine but since I`m a new VB-to-VC++ learner I can hardly do that stuff in VC++ language.
Again thank you so very much for your respond!
Regards.
|
|
|
|
|
It's SO much easier to do this in VC than in VB. If you use MFC, simply hook up a virtual function override for WindowProc (with ClassWizard), and put this code in it:
if( message == WM_POWERBROADCAST )
{
switch( wParam )
{
case PBT_APMQUERYSUSPEND:
{
return BROADCAST_QUERY_DENY;
}
}
}
There ya go, done! If you don't use MFC, simply put a case for WM_POWERBROADCAST in your already existing WindowProc.
Chris Richardson Terrain Software
|
|
|
|
|
Yeap! It`s so MUCH easier. Just a less-than-a-minute work. Great thanks, Chris Richardson! Both MFC and non-MFC work fine.
Thanks to Duncan, too. Hoping this thread useful for the community.
Regards.
|
|
|
|
|
Im on w2k/ntfs, and i would like to set file/dir access permissions, but it just won't work like i imagine.
Im using SetFileSecurity(), and i also tried SetSecurityInfo(), but with both i could not set the rights like i set them when i click on the checkboxes in file properties dialogs. Mainly i missed how to set property that it would inherit to "This folder, subfolders and files" instead of only "This folder".
Can anyone help me, or point to some article ? thanks in advance
cheers
mirex
-- edit --
Now i found how to do it, it can be done when adding ACL record by SetEntriesInAcl(); you can specify inheritance in EXPLICIT_ACCESS structure
|
|
|
|
|
I've lately been having trouble with services (on win2k) if their ImagePath registry entry has spaces in the path and no quotes around the executable name. Even though the Platform SDK stresses that quotes are needed in ImagePath if the executable name / path has spaces, there are even some Visual Studio services that don't follow this rule. The symptom is a cryptic Message Box showing text such as: Could not start the yadda-yadda service on Local Computer. Error 193: %1 is not a valid Win32 application.
We have not been able to determine what caused win2k to suddenly require quotes around service paths. I keep up-to-date with WindowsUpdate patches, but we patched a clean machine and this problem did not occur there. Does anybody have any ideas or suggestions?
Thanks,
Eric T.
|
|
|
|
|
Eric at Cognos wrote:
no quotes around the executable name
You must have quotes around any paths in the command line in case they might have spaces. If you don't do this, you'll run into trouble. If other services get away with it, it's only luck.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I've been fighting a long battle to make DNS work in Win2K. Most of the problem is certainly my own ignorance, but perhaps someone here can enlighten me. My server and its rarely used clients are members of the Windows domain "myplace.com," and I have registered an Internet domain by the same name. My registrar, Register.com, maintains the primary DNS SOA for the Internet domain, but when Windows installs DNS it creates a default zone and insists on making itself the SOA. This seems to be a conflict, as only one SOA can exist for a zone. My only reason for using DNS locally is that I want to gain experience with Active Directory, and AD requires a DNS server.
The symptoms of the problem are two-fold: the netdiag utility reports that there are no DC records for this Domain Controller registered with any DNS system [fatal error], and the System log fills completely every two or three days with 5774 errors. I've exhausted every MS KB article that mentions this error and none come close. Is there any way to resolve this? It would seem from my research that no one else in the entire world has ever run into this scenario, and I find that hard to believe. The DNS books and chapters I've read imply that it's a simple matter of setting up a zone, but the instructions don't work, and none mention the fact that Windows creates its own default site, nor give any suggestions about what to do with it. Any clues would be most welcome!
"Please don't put cigarette butts in the urinal. It makes them soggy and hard to light" - Sign in a Bullhead City, AZ Restroom
|
|
|
|
|
I have done this once before and set it up (Using Microsoft Small Business Server) so that the external domain and the internal domain were different.
For example, the external domain hosted by my ISP was set up for 'companyname.com' and the internal domain was set up for 'companyname.local'. All that needs to be done then is to have the ISP point the MX records to the IP address of the server for email name resolution (and some other things need to be done inside of Exchange as well).
Here is a decent tech note to get you started:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;296250[^]
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I hadn't seen that before, though I spent 4 years trying to make a SBS4.5 network do anything at all correctly. Worst technical recommendation I ever made...
I'd really like to find a solution that doesn't require renaming the internal network, as that has a lot of repercussions I don't want to deal with. Surely there's some way to accomplish this - it isn't that unusual a situation. If nothing else works, though, I guess I'll have to resort to doing so.
"Please don't put cigarette butts in the urinal. It makes them soggy and hard to light" - Sign in a Bullhead City, AZ Restroom
|
|
|
|
|
Hi.
This is a general discussion post, that i've posted in the System Administration forum as well.
I've come to a point where i have a finished ASP.NET web application that i want to distribute. It use ASP.NET web as a front-end, .NET Windows as a front-end for the SQL Server backend db.
I want to create some sort of installation package for my application. I should do the following things:
1) Create FTP login
2) Create Virtual Directory in IIS
3) Copy ASP.NET files to virtual directory
4) Duplicate SQL database
5) Update web.config file in ASP.NET app.
At the moment i have some issues on point 4. What is the best approatch on duplicating SQL server databases programaticly. Are there any pre-made serverinstaller packages? Got any good articles/guitlines on the subject?
In general, i need some info on what is the best approatch to take when distributing a server app.
-Jonas
|
|
|
|
|
Jonas Follesø wrote:
At the moment i have some issues on point 4. What is the best approatch on duplicating SQL server databases programaticly. Are there any pre-made serverinstaller packages? Got any good articles/guitlines on the subject?
You can create a custom action for your MSI installer, simply by creating an "Installer Class" (select it from the File/Add New Item).
IIRC, there is a sample for creating a database in a custom action on MSDN, but sorry, I can't remember where now.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
I am trying to set up a domain on 2k3 server but whenever I log on to my computer via domain (user is member of Administrators) I am on a limited account and can't even change the time. I have rebooted both the computer and the server and can't figure it out. Does anyone have any experience with this?
Matt
|
|
|
|
|
Hey guys,
I'm in the process of setting up a small network here at home (3 computers). We have a DSL connection, and I wanted a DHCP server, so I went out and got a linksys router and set everything up. Well, my XP Pro laptop is working fine, and my roommate's Win2K box is working fine, but my other roommate's XP Home box will not connect. We bought a linksys 10/100 netword card and installed it, and XP recognizes that it's there and installed the drivers, but for some reason, his machine cannot communicate with the router. The network icon is there on the system tray (and showing the connected state), and the LEDs on the card are lit up, but it just won't work.
Does anybody have any ideas what could be the problem?
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
Chris Richardson wrote:
The network icon is there on the system tray (and showing the connected state), and the LEDs on the card are lit up,
It's probably not the card... A couple of things to check:
Are they all using the same subnet as the local port of the router? Is the gateway of the XPHome PC set correctly by the router's DHCP Server? Have you tried putting them all in the same workgroup (it shouldn't matter if all you're sharing is the Internet, but XPHome is weird)? Can you ping the router from the XPHome machine? How about the DSL IP address?
Obvious things, I know, but it's awfully easy to miss a step or take something for granted...
"Please don't put cigarette butts in the urinal. It makes them soggy and hard to light" - Sign in a Bullhead City, AZ Restroom
|
|
|
|
|
First, thanks for the response! Here's what I've found out:
1. I can ping the router, but can't access it with IE like I can on my XP laptop or the 2K box.
2. I can ping the DSL modem from the XP home box.
(didn't think of pinging either of these devices before...thanks)
3. I can access my laptop from the XP home box, even through explorer.
The TCP/IP settings are exactly the same on both XP boxes, so I'm thinking maybe it's just IE that's messed up on his XP home box.
Thanks again, now that I know the card is not messed up, I hope I can figure out what's going on with IE.
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
If you can reach the network via ping and perhaps tracert, then the network card and the network doesn't seem to be the problem. Once you have determined you can ping another host on your own network try performing a trace route using tracert to an external host such as codeproject. Keep in mind that depending on the routers that are between your network and the destination network you may get some timeouts. Try several external hosts that you know are not using the same route. Once you can determine that your are at least reaching your ISP's router you know any other network problems are outside your control.
As for application specific issues such as IE, check the proxy settings for the application. IE may have been set to connect to a proxy server that it does not have access to on your network.
You might also try using another application that will utilize an alternate protocol. Try using FTP to go to a public FTP site.
|
|
|
|
|
If the gateway IP is set to the local port of the router, and the XP box is on the same subnet, IE should have no trouble connecting. In Tools/Internet Options/Connections, there should be no connection information. Click on LAN Settings, and make sure that no boxes are checked - the Automatic and Proxy options will interfere with the box working properly, in particular.
I haven't used the Home version - it's so badly crippled it isn't worth considering - but I'd also suggest that you review permissions for the user account. There may be a new one that restricts access to the Internet. Also, many OEMs preconfigure Windows with what they think most users will want. If yours has ICS installed and it's not acting as the gateway for your network, get rid of it, along with that stupid excuse for a firewall that comes with it.
"Please don't put cigarette butts in the urinal. It makes them soggy and hard to light" - Sign in a Bullhead City, AZ Restroom
|
|
|
|
|
How can I connect a client application running behind a proxy to a web server?
The connection cannot be a direct TCP to the server as the proxy is in between. I can have a Http connection , the way a browser works. But how do I achieve it. Any suggestions??
|
|
|
|
|
Your questions is a bit general to give you a specific answer. Let me lay out some examples.
Let's say you have an client application that will be using the HTTP protocol to contact a server. If you want the client app to make all transactions via a proxy you would need to configure the client app to connect to the proxy itself. If you are using the HTTP protocol, then you would tell the proxy what destination server you want your request forwarded to and the proxy would then interpret that request and perform it, and return the results to you.
How you make the connection via a proxy really depends on the type of protocol. Take the SMTP protocol for example. This protocol was not originally designed to be a proxied protocol. However, that doesn't mean you can't proxy it. In this case you would configure your mail client to connect to the proxy when sending mail. The proxy would then be configure to connect to the real server. In this scenario, the client would not know that all of it's requests are being forwarded to the real server.
Hope that helps.
|
|
|
|
|
What I have read about Http CONNECT is that it is used to establish a secure connection to the server.Does that mean that I can connect only to port 443 of the Listner i.e. server?
Can I connect to the port 80 of the server i.e specify the ip address:80 in the CONNECT method
|
|
|
|
|
There is nothing special about the port. It is just a commonly chosen port of 443 for HTTPS and 80 for HTTP. If you want to make a non-secure connection then you make your connection and don't negotiate an SSL session. Of course the server you connect to must be expecting a non secure connection, which most do.
Let's say you want to connect to codeproject from your browser. If you were to connect directly from your application, it would open a TCP connection via port 80 and send something similar to the following.
GET / HTTP/1.1
Accept: */*
Accept-Language: en-us
User-Agent: Your application name here
Host: www.codeproject.com
What will be returned will be the contents of the page requested. You can test this using telnet. Open a telnet session to your own server on port 80 and type the above text. End the text with two carriage returns to get the results.
Now if you wanted to do the same request via a proxy you would do something like this.
GET http://www.codeproject.com/ HTTP/1.1
Accept: */*
Accept-Language: en-us
User-Agent: Your application name here
Host: www.codeproject.com
There is very little difference. In this case you supply the host and protocol portion of the URL instead of just the path. This is because the proxy needs to know the name of the host you want to connect to. Instead of connecting to port 80 on codeproject you would connect to port 80 on your proxy server. Of course your proxy could use any port you wish. Port 80 is the standard, but it could easily be 8080 or some other port of you chosing.
If your proxy understands other protocols such as https, ftp, gopher, or a custom protocol then you could use those by simply modifying the URL passed.
|
|
|
|
|
How can I know when to use a 3 state model or a 5 state model or a 7 state model for processes as they are created, runned and terminated.
This is for a project.
PitoPR
|
|
|
|
|
This is odd. Windows Explorer shows that my C: drive has 5490MB in use, but if I total the used space for all of the folders on the drive it comes to only 3716MB - size on disk, not file size. Which value is 'real'? And why is there such a huge discrepancy?
"Please don't put cigarette butts in the urinal. It makes them soggy and hard to light" - Sign in a Bullhead City, AZ Restroom
|
|
|
|
|
It may be because of cluster size. On a large drive, the cluster size is about 32KB. So space is used up in blocks of 32KB. This means that the minimum amount of space a file can take up is 32KB, and if it was, say, 35KB, it would have to take up 64KB of actual disk space.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|