Quantcast
Channel: General Windows Desktop Development Issues forum
Viewing all 6180 articles
Browse latest View live

udp external port number compatibility windows / linux c/c++

$
0
0

I'm having fun here in Ireland trying to develop a Video and Sound Chat Room

I'm using Visual C++ under Windows 7 for the Client

and C and Linux for the server.

and UDP for the router bypass technology

I seem to have hit a dead end with the external port numbers

If I get a window client (behind a router) to access a WINDOWS server, the server can get the

external port number and contact the client through the router. That's easy. I can even write a second program and access the client that's behind the router using the same external port number.

Similarly if I get the windows client (behind the router) to access the LINUX server the Linux server can do exactly the same thing and make contact with the calling program using the external port number, and again I can stop the server and use another little program and contact the client behind the router by using the same external port number.

Here's the hassle

I want to get the windows client (behind the router) to access the linux server, the linux server to ascertain the external port number and then use that external port number to access the calling program FROM ANOTHER WINDOWS CLIENT.

The trouble is Linux established the external port number it can only be used in linux and if windows establishes it, it can only be used in windows.

The two systems must be holding the port numbers in a different format

I have tried ntohs and htons as they sort out an 'endian'  problem. I certainly thought  that they would provide the solution but they do not.

There must be a very simple solution to this as without it nobody could have windows clients and linux servers.

I'd be very grateful if anybody could point me to a worked example but I have looked for quite some time and this one eludes me yet.

Peadar Dublin, Ireland Tuesday, December 2 2014

====================================================================

This is the Windows Server Code


    memset((

char*) &si_me, 0,sizeof(si_me));

    si_me.sin_family =

AF_INET;

    si_me.sin_port = htons(

PORT);

    si_me.sin_addr.

s_addr= htonl(INADDR_ANY);

   

if(bind(ServSock, (structsockaddr*)(&si_me),sizeof(si_me))==-1)

{

AfxMessageBox(

"problemwith bind");

WSACleanup();

        diep(

"bind");

}

   

if(recvfrom(ServSock, buf,BUFLEN, 0, (structsockaddr*)(&si_other),&slen)==-1)

{

AfxMessageBox(

"problemwith recvfrom");

WSACleanup();

        diep(

"recvfrom");

}

    sprintf_s(ErrLine,

"Received packet from %s:%d\n", inet_ntoa(si_other.sin_addr), ntohs(si_other.sin_port));

    AfxMessageBox(ErrLine);

WSACleanup();

    closesocket(ServSock);


====================================================================

This is the Linux Server Code

    struct sockaddr_in my_addr;

    memset(&my_addr, 0, sizeof(my_addr));

    my_addr.sin_family      = AF_INET;

    my_addr.sin_port        = htons(real_port);

    my_addr.sin_addr.s_addr = INADDR_ANY; 

    int bindret = bind(fd, (const struct sockaddr *)&my_addr, sizeof(my_addr));

    if (bindret < 0)

    {

        fprintf(stderr, "Unable to bind to port %d.  errno %d\n", port, errno);

        return 7;

    } 

    uint32_t * last_addr;

    uint16_t * last_port;

    char buf[sizeof(*last_addr) + sizeof(*last_port)];

    memset(buf, 0, sizeof(buf)); 

    last_addr   = (uint32_t *) (buf          );

    last_port   = (uint16_t *) (last_addr + 1); 

    uint32_t iter;

    struct sockaddr_in  next_data;

    socklen_t           next_len    = sizeof(next_data);

    memset(&next_data, 0, sizeof(next_data)); 

    ssize_t recvret = recvfrom(fd, NULL, 0, MSG_TRUNC, (struct sockaddr *) &next_data, &next_len);

    if (recvret < 0)

    {

        printf("Error on recvfrom.  errno %d\n", errno);  fflush(stdout);

        return 3;

    }

    inet_ntop(AF_INET, &next_data.sin_addr.s_addr, TmpString, INET_ADDRSTRLEN);

printf( " \n\nthe port that we are using to send stuff back is     %d   \n\n" ,next_data.sin_port); fflush(stdout);

printf( " \n\nthe ntohs converted version is %d   \n\n" ,ntohs(next_data.sin_port)); fflush(stdout);

close (fd);

return 0;

}

====================================================================



Smartscreen

$
0
0

Greetings to all.

These days I'm making a small desktop application that simply connects to our site and makes you see the messages contained on the html page. When we download the .exe file from our site ... owners of Windows 7 do not have problems, while those with windows 8 are warned that it could be a malicious file.

We then (as several articles on the net) bought a certificate to sign our executable. Signed with timestamp. Now the browser is no longer aware that the file could be bad, but when you run it the first time the SmartScreen continues to give notice that hateful.

I have read here and there that we must also make a reputation, but I can say to all our clients that even if that message says that our program could be harmful in reality it is not, also do not know how many executions serve or otherwise.

Someone who has had the same problem? How can I fix it?

Maybe I forgot something in the code or maybe need a certified more pro ... but I've seen that some file type putty.exe that have neither signed nor anything not stopped

Thank you all for the advice Fabrizio

Saving User Authentication Credentials of wireless WPA2-Enterprise profiles

$
0
0

Hi,

I am developing the Application for configuring all types of wlan profiles for that i am using Wlan Apis. In my application i don't want to use the default profile properties windows(which will come by using WlanUIEditProfile) so i created the my own ui for that. Now i am facing the problem for storing the PEAP credentials. Is there any way to replicate the functionality of "Save credentials" button in the "802.1x settings" menu using Windows API? Or some other way to permanently save the PEAP credentials for the wireless profile.

Thanks in Advance


Find Name of Named Pipe Given Named Pipe Handle

$
0
0
I'm trying to retrieve the name of a named pipe given it's handle. For example the handle generated by CreateNamedPipe.

I found a way to do so by creating a duplicate of the handle using NtDuplicateObject and then using NtQueryObject on the duplicate. Sadly I've been told I can't use NtQueryObject because it is unsupported/undocumented like many native API functions.

Are there any alternatives or workarounds? Appreciate any feedback.

Trying to batch print a group of html files?

$
0
0

Ok I have been trying for two days now to get this to work.

I will have a list of html files that I will loop thru and I want to print out to a specific printer.

This needs to be automated. No user interaction with it.

So I have tried the webbrowser control, no help.

And I have tried the ProcessStartInfo, no help there either.

What I have atm;

Dim proStart As New ProcessStartInfo
proStart.FileName = (My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\TheBill.html")
proStart.Verb = "print"
 'proStart.UseShellExecute = True
 'proStart.CreateNoWindow = True
proStart.WindowStyle = ProcessWindowStyle.Hidden                   
Process.Start(proStart)

with this line commented out, proStart.WindowStyle = ProcessWindowStyle.Hidden  , I get the system print dialog that pops up and the user has to click the print button. Then the doc prints out as it should.

With it not commented out I get nothing! no error msg and no print out!.

What am I missing?

Note! the file is at C:\theBill.html for these tests.

Thanks

Deasun

Desktop Apps for Windows Store I have done Windows App Cert check and PASSED what do I do next?

$
0
0

Hi,

I developed a desktop app and it passed the SDK App Cert Check and need to know what to do next. I am registered as a developer not a company and when the cert check passed it wanted me to go to a dasboard that only companies are allowed access to. What do I do?

Thanks,

-Tony

paths used by SearchPath system call when called with NULL as first argument

$
0
0

Hi,

It's not clear to me what paths the SearchPath system call is using to search for executables. I wrote a small program that searches for java.exe.

On Windows 7, java.exe is found under C:\Windows\system32 even if I have another java.exe in "C:\Program Files\Java\jdk1.8.0_25\bin" directory which appears first in my PATH environment variable.

On Windows 8, java.exe is found under C:\Program Files\Java\jdk1.8.0_25\bin as expected.

So why is SearchPath(NULL, ...) behaving differently between the 2 OS versions and can you explain which system path is search by SearchPath(NULL, ...) on both systems?

Here's my small test program:

#include <iostream>
#include <windows.h>

using namespace std;

int
main(int argc, char**)
{
    char buf[8192];
    GetEnvironmentVariable("PATH", buf, sizeof(buf));
    char buf2[_MAX_PATH];
    char* addr;
    SearchPath(0, "java", ".exe", _MAX_PATH, buf2, &addr);
    cerr << buf2 << endl;
    SearchPath(buf,  "java", ".exe", _MAX_PATH, buf2, &addr);
    cerr << buf2 << endl;
}

Benoit

Deactivate Bluetooth Page/Inquiry Scans

$
0
0

Is it possible to deactivate page/inquiry scans with setsockopt() in win 8.1 like it it is in win CE? Or via HCI commands? If latter, how do I do that in c++ using winsock2? Or is it enough to set the device unconnectable and discoverable?


In win CE i have the option to use SO_BTH_SET_SCAN as optname, like this:

setsockopt( LocalSocket, SOL_RFCOMM , SO_BTH_SET_SCAN , (const char*)&scanMode, sizeof(char));

But this does not seem to exist in desktop windows' winsock.


I want to do this because page scan windows cause packet losses (or massively higher latencies) for the target application. The application itself has high demands on both latency and data rate.






COM server Failed to register

$
0
0

After I create package and install the software on the mechine where source code is located where software works fine (This machine is window 2000)

 

After burn the copy of the package software I install the software to other machine(Window XP) give me error when registering COM Server

is " COM Server Failed to Register"

 

 

 

 


Vijay Patel

Secure Digital Card with IOCTL_SFFDISK_DEVICE_COMMAND CMD56

$
0
0
Hello guys,

I work on my notebook with Windows XP as OS and I use an internal card reader for my SD-card. It's a normal SD memory card, not a SDIO.
I use IOCTL_SFFDISK_DEVICE_COMMAND for performing SD commands.

I'm able to get CSD and CID-Register of the memory card.
Now I want to perform CMD56 (General Purpose Command) in the way like CSD and CID-Register, but I'm not able to do this.
Everytime I get an Error 5: Access denied.

My question now: It is possible to perform this CMD56 or it's basically not possibile (not supported from native SD device driver sffdisk??)

Here is my sample code:
	// Get drive letter
	String ^str_drv = this->comboBox1->SelectedItem->ToString();
	array<wchar_t>^ char_drv = str_drv->ToCharArray();
	wchar_t drv_path[20] = L"\\\\.\\C:";
	drv_path[4] = char_drv[0];

	HANDLE drv_hdl;
	drv_hdl = CreateFile((LPCWSTR)drv_path,  GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
						  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(INVALID_HANDLE_VALUE == drv_hdl)
	{
		result = GetLastError();
		MessageBox::Show("Can not open drive.", "ERROR!!!", MessageBoxButtons::OK);
		drv_hdl = NULL;
		return;
	}

	/*********************************
	*
	*	OPEN DRIVE
	*	is done successfully
	*
	*********************************/

	//get device number of the drive
	STORAGE_DEVICE_NUMBER vol_disk;
	result = DeviceIoControl(drv_hdl, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0,
    						 (LPVOID) &vol_disk, (DWORD)sizeof(vol_disk),
	     					 (LPDWORD) &count_of_bytes, (LPOVERLAPPED)NULL);
	if((0 == result) || (sizeof(vol_disk) != count_of_bytes))
	{
		result = GetLastError();
		MessageBox::Show("Can not get the device number.", "ERROR!!!", MessageBoxButtons::OK);
		CloseHandle(drv_hdl);
		return;
	}

	/*********************************
	*
	*	GET DEVICE NUMBER
	*	is done successfully
	*
	*********************************/

	//open device
	wchar_t dev_path[20] = L"\\\\.\\PHYSICALDRIVE";
	dev_path[17] =(wchar_t) (vol_disk.DeviceNumber + '0');

	HANDLE dev_hdl = CreateFile((LPCWSTR)dev_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
					  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(INVALID_HANDLE_VALUE == dev_hdl)
	{
		MessageBox::Show("Can not open the device.", "ERROR!!!", MessageBoxButtons::OK);
		CloseHandle(drv_hdl);
		dev_hdl = NULL;
		drv_hdl = NULL;
		result = GetLastError();
		return;
	}


	/*********************************
	*
	*	OPEN DEVICE
	*	is done successfully
	*
	*********************************/


		// Declare Variables
	int buffSize = 0;
	int nSizeofCmd = 0;
	SFFDISK_DEVICE_COMMAND_DATA *pCmd;
	SDCMD_DESCRIPTOR sdCmdDescriptor = { 0 };
	DWORD dwBytesReturned = 0;
	BOOL bResult;
	BYTE outputData[512] = {0};
	BYTE inputData[512] = {0};
	SFFDISK_DEVICE_PASSWORD_DATA	*pCmdPW;



	// ********************************************************************************
	// Start Command CMD56: GEN_CMD WRITE ->

	// Build Structure SFFDISK_DEVICE_COMMAND_DATA for lpInBuffer in DeviceIOControl
	buffSize = 512; // One data block
	nSizeofCmd = sizeof (SFFDISK_DEVICE_COMMAND_DATA) + sizeof(SDCMD_DESCRIPTOR) + buffSize;

	pCmd = (SFFDISK_DEVICE_COMMAND_DATA*) new BYTE[nSizeofCmd];
	memset(pCmd, 0, nSizeofCmd);
	pCmd->HeaderSize = sizeof (SFFDISK_DEVICE_COMMAND_DATA);
	pCmd->Reserved = 0;
	pCmd->Command = SFFDISK_DC_DEVICE_COMMAND;
	//pCmd->Command = SFFDISK_DC_GET_VERSION;
	//pCmd->Command = SFFDISK_DC_RESERVED1;
	//pCmd->Command = SFFDISK_DC_RESERVED1;

	pCmd->ProtocolArgumentSize = sizeof (SDCMD_DESCRIPTOR);
	pCmd->DeviceDataBufferSize = buffSize;
	pCmd->Information = 0;	// Argument bit[0] = 0 for write


	///Build sdCmdDesriptor, which is located as data member in SFFDISK_DEVICE_COMMAND_DATA structure
	memset(&sdCmdDescriptor, 0, sizeof(sdCmdDescriptor));

	sdCmdDescriptor.Cmd = 56; // GEN_CMD
	//sdCmdDescriptor.Cmd = SDCMD_IO_RW_DIRECT;
	//sdCmdDescriptor.Cmd = SDCMD_IO_RW_EXTENDED;

	sdCmdDescriptor.CmdClass = SDCC_STANDARD;
	//sdCmdDescriptor.CmdClass = SDCC_APP_CMD;

	sdCmdDescriptor.TransferDirection = SDTD_WRITE;
	//sdCmdDescriptor.TransferDirection = SDTD_READ;
	//sdCmdDescriptor.TransferDirection = SDTD_UNSPECIFIED;

	sdCmdDescriptor.TransferType = SDTT_SINGLE_BLOCK;
	//sdCmdDescriptor.TransferType = SDTT_UNSPECIFIED;
	//sdCmdDescriptor.TransferType = SDTT_CMD_ONLY;
	//sdCmdDescriptor.TransferType = SDTT_MULTI_BLOCK;
	//sdCmdDescriptor.TransferType = SDTT_MULTI_BLOCK_NO_CMD12;

	sdCmdDescriptor.ResponseType = SDRT_1;
	//sdCmdDescriptor.ResponseType = SDRT_UNSPECIFIED;
	//sdCmdDescriptor.ResponseType = SDRT_NONE;
	//sdCmdDescriptor.ResponseType = SDRT_1B;
	//sdCmdDescriptor.ResponseType = SDRT_2;
	//sdCmdDescriptor.ResponseType = SDRT_3;
	//sdCmdDescriptor.ResponseType = SDRT_4;
	//sdCmdDescriptor.ResponseType = SDRT_5;
	//sdCmdDescriptor.ResponseType = SDRT_5B;
	//sdCmdDescriptor.ResponseType = SDRT_6;

	// Copy sdCmdDescriptor in Data Member area of SFFDISK_DEVICE_COMMAND_DATA Structure
	memcpy((BYTE *)(&(pCmd->Data[0])), &sdCmdDescriptor, sizeof(SDCMD_DESCRIPTOR));


	// For Data Line
	memset(inputData, 0, sizeof(inputData));
	//for(int i=0; i<sizeof(inputData); i++)
	//	inputData[i] = i;

	// Copy DataBuffer in Data Member area (after sdCmdDescriptor) of SFFDISK_DEVICE_COMMAND_DATA Structure
	memcpy((BYTE *)(&(pCmd->Data[0]) + sizeof (SDCMD_DESCRIPTOR)), &inputData, sizeof(inputData));



	/*********************************
	*		Desired Procedure
	* Host sends CMD56
	* Card responses with R1
	* Host send one datablock over DAT-Line
	*********************************/
	// Start Request
	dwBytesReturned = 0;
	bResult = DeviceIoControl(drv_hdl, IOCTL_SFFDISK_DEVICE_COMMAND, pCmd, nSizeofCmd, pCmd, nSizeofCmd, &dwBytesReturned, NULL);
	if(bResult == 0)
	{
		result = GetLastError();
		MessageBox::Show("CMD56 GEN_CMD Write failed: Error Number: " + result, "ERROR!!!", MessageBoxButtons::OK);
	}
	else
	{
		MessageBox::Show("CMD56 GEN_CMD Write was successful", "SUCCESS!!!", MessageBoxButtons::OK);
	}

	// Free Memory
	free(pCmd);

If you can give me an advise. please let me know.
Many thanks in advance.

0xc0000022 Error but only when on French Version of Win 7 on a User Account

$
0
0

I'm stumped.

I provide an application to support a camera. We've got an installed based of over>8000 without any issues.

I have one customer using Win7 built from -Win_Pro_7W_SP1_S64BIT_French_MFL_X17-28731.ISO 

When the application is started ,  this error message is presented * 0xc0000022* and the application will not start from  USER Accounts. Admin Accounts  work properly. 

On All other versions of Win7 installs do not have this problem. Both Admin and User Accounts run properly. The French version of Win7 is the only one (that I know of) that has this problem.

My installation software is QSetup by Pantaray. The install script is run from an Admin account using the option to install software for all users. User accounts generate the  0Xc0000022 error message. Admin Accounts work fine. This error on appears Only with the French Win7 ISO install referenced above.  Win7 systems built from English ISO work fine on both User and Admin accounts. 

Thanks in advanced for any suggestions
Randy


Randy Feingersh

Creating and printing a document

$
0
0

The purpose is to create a template containing a table with some text given by user and then print it. Intermediate file is not required if it can be done without it.

I see 2 steps here:

0) Generating document data

It can be performed in at least 4 ways:

  0.0) Automating Word for creating table and filling in the fields. COM and Office automation knowledges required, needs more time and resources for quite simple task;

  0.1) Creating an RTF document manually (or not) for further processing with RichTextBox control. Requires less time and resources for programming;

  0.2) Generating an HTML page. Easiest way for making document itself, but I don't know how to print it then.

  0.3) Rendering a table with text into vector image. Average time for coding.

1) Printing the data

Terra incognita for me :D I've never made it, so if simple printing of plain text or image doesn't seem to be a heavy task, trying to output something more complicated (RTF/HTML/WMF) can be very difficult for me.

Can you comment each variant (except Word maybe) and help me how to output prepared data to printer?


If I fall I will arise on my way to paradise

On lid close power settings customization

$
0
0

Hey there.

I've been trying to change the power policy settings. To be precise, I've been trying to change the action upon closing the laptop's lid. So far, I've seen two ways to do that. First way, for windows XP:

GLOBAL_POWER_POLICY globalPowerPolicy;
BOOLEAN success = ReadGlobalPwrPolicy(&globalPowerPolicy);
if(success)
{
     globalPowerPolicy.user.LidCloseAc.Action = POWER_ACTION::PowerActionNone;
     globalPowerPolicy.user.LidCloseDc.Action = POWER_ACTION::PowerActionNone;
     success = WriteGlobalPwrPolicy(&globalPowerPolicy);
}


Second way, for windows vista and above:

GUID* pGuidActivePwrSchm = NULL;
DWORD dwR = PowerGetActiveScheme(NULL, &pGuidActivePwrSchm);
if(dwR == ERROR_SUCCESS)
{
     dwR = PowerWriteACValueIndex(NULL, pGuidActivePwrSchm, &GUID_SYSTEM_BUTTON_SUBGROUP, &GUID_LIDCLOSE_ACTION, 0);

     if(pGuidActivePwrSchm)
     {
          PowerSetActiveScheme(NULL,pGuidActivePwrSchm);
          LocalFree(pGuidActivePwrSchm);
          pGuidActivePwrSchm = NULL;
     }
}

I am also using the snippet below to check the current action upon closing the lid:

GLOBAL_POWER_POLICY globalPowerPolicy;
BOOLEAN success = ReadGlobalPwrPolicy(&globalPowerPolicy);
if(success)
{
     if(globalPowerPolicy.user.LidCloseAc.Action == POWER_ACTION::PowerActionNone && globalPowerPolicy.user.LidCloseDc.Action == POWER_ACTION::PowerActionNone) {
          return true;
     }
     return false;
}

So, what I do is I get into the control panel, set the action (for both AC and DC) to "Sleep", and then run my snippet above, to check if it detects current action properly. It does.

Then, I run first snippet, for windows XP. The outcome is as predicted: my code to check current action returns unchanged values.

Then, I run the second snippet, supposedly for windows vista and above. The outcome is as predicted aswell: my code to check current action returns proper, changed values (same value for DC, different for AC. But that's as expected.)

So, full of joy and happiness, I navigate to the control panel, to check if the values really did change. They didn't. They're just as they were, but my code tells me otherwise.

To make the final judgement, I shut the lid down, to see what's true and what's not. My computer goes asleep, just as the settings in control panel tell me.

So, my question is: how do I fix that? Why it doesn't work?

Cheers.

Merging two vertex buffers

$
0
0

I have created two different vertex and index buffers for two different objects. Then I merged those two vertex vertex and index buffers into one vertex and index buffer and send them to input assembler ,I drawed them one by one,But just the first object is being drawn ,the second not.When I use two different buffers everything is Ok but with one large vertex buffer not. Am I missing something in my code, or have I done something wrong? What to do to draw them both.

Here is some part of my code :

ID3D11Buffer * mPiramidVertex;
ID3D11Buffer* mPiramidIndex;
ID3D11Buffer*secondVertex;
ID3D11Buffer* secondIndex;
...


UINT stride[] = { sizeof(Vertex), sizeof(Vertex) };
	UINT offset[] = { 0,0 };
	ID3D11Buffer* twoBufers[2] = { mPiramidVertex,secondVertex };
	ID3D11Buffer* twoindices[2] = { mPiramidIndex,secondIndex };
mdevicecontexct->IASetVertexBuffers(0, 2, twoBufers, stride, offset);//merging vertex buffers
	mdevicecontexct->IASetIndexBuffer(*twoindices, DXGI_FORMAT_R32_UINT, 0);//merging index buffers

XMMATRIX view  = XMLoadFloat4x4(&mView);
	XMMATRIX proj  = XMLoadFloat4x4(&mProj);

D3DX11_TECHNIQUE_DESC Desc;
    mTech->GetDesc( &Desc );

    for(UINT p = 0; p < Desc.Passes; ++p)
    {

		XMMATRIX world = XMLoadFloat4x4(&mWorld);
		XMMATRIX worldViewProj = world*view*proj;
		mfxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj));
        mTech->GetPassByIndex(p)->Apply(0, mdevicecontexct);

		mdevicecontexct->DrawIndexed(18, 0, 0);//first object has 18 indices and 5 vertices.
		mdevicecontexct->RSSetState(fillSolid);


		world = XMMatrixTranslation(0.0f, 1.0f, 0.0f);
		worldViewProj = world*view*proj;
        mfxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj));
		mTech->GetPassByIndex(p)->Apply(0, mdevicecontexct);

		mdevicecontexct->DrawIndexed(36, 18, 5);//second object has 36 indices and 8 vertices.
		mdevicecontexct->RSSetState(fillSolid);
    }

	HRESULT(mSwapChain->Present(0, 0));


Admir


Screen Saver event notification under windows 7 for C# . NET 4.5

$
0
0

I need to detect when the screen saver is activated and suspended under windows 7, I am developing VS 2012, C# for .NET 4.5

I need the event notification, not a function that detects if the screen saver is running or not. I need the actual windows event to know exactly when the screen saver starts and stops.

Thank you



Service not starting on Win8/Win2012

$
0
0

Hi folks!

Oddest thing. I have a service and its associated console, both 32bit built in VB2008. The service is set to be auto-started upon Windows launch. Everything works fine on WinXp, Vista, Win7 and Win2008.

But on Win8 and Win2012:

- Windows does not auto-start the service upon Windows launch (even though the service properties specify to do so)

- the console can't start/stop the service either. The service can only be started/stopped by going into the Services dialog of Windows and manually starting it.

I know that the Administrator is not the same in Win8 and Win2012 as it was in prior Windows versions.  Would I need to start compiling the service and/or the console with "requireAdministrator" or "highestAvailable" instead of "asInvoker" in the manifest?  Would manifest need to be altered in some other fashion?

Does this ring a bell for anyone? Thanks!

Problem writing to WinUSB pipe - The I/O operation has been aborted..."

$
0
0

Hi,

I am developing an app using Visual Studio 2005 and WinUsb. The OS  is Windows 7 and XP .

The app is communicating via USB with our embedded software based on Micrium OS.

I am using asynchronous I/O. It generally works, but occasionally I am getting a failure when I call WinUsb_WritePipe and WinUsb_GetOverlappedResult:

WinUsb_WritePipe returns immediately False and GetLastError returns ERROR_IO_PENDING. Then I call WaitForSingleObject waiting 1 sec and after that I call WinUsb_GetOverlappedResult to retrieve the result. The result is False and GetLastError returns : “The I/O operation has been aborted because of either a thread exit or an application request” error.

It happens very rely but it does happen. Is this Windows issue or embedded software? – or maybe I am doing something wrong. Any idea how to diagnose where the fault is?

Regards,

Janusz 

Why event log record number does not reset to 0 after reaching ULONG_MAX?

$
0
0

This post is continuing the question of this post:

https://social.technet.microsoft.com/Forums/windowsserver/en-US/25c7bdba-258b-44e6-87ba-d40e68b6b4e2/resetting-the-eventrecordid-for-a-windows-2008-r2-event-log?forum=winservergen

That post has been marked answered so I am concerned it will not get attraction anymore. This is why I create a new thread here. Sorry if there is any redundancy.

According to MSDN,

The RecordNumber member of EVENTLOGRECORD contains the record number for the event log record. The very first record written to an event log is record number 1, and other records are numbered sequentially. If the record number reaches ULONG_MAX, the next record number will be 0

This means RecordNumber should never exceed ULONG_MAX which is about 4 billion. How can people get RecordNumber of 18 billion? Does this mean there is some bug in windows event log? Thanks for clarification.

IFileSaveDialog save over Read-Only File

$
0
0

Hey Everyone,

I'm trying to figure out a way to force save over a read-only file when utilizing a IFileSaveDialog. Originally I thought maybe there was an option that I can set via IFileDialog::SetOptions that would bypass the error messagebox that appears when I select a read-only file to save over so that I can then use SetFileAttributes() to remove the read-only attribute from the selected file. Unfortunately, I was not able to find this option, as I tried both FOS_NOTESTFILECREATE and FOS_NOINVALIDATE.

I was also looking around for a way to grab the filepath after the save button is selected, but before it recognizes that the file is read-only, but really had no idea where to go with that. I was thinking maybe I should pass a handle into IModalWindow::Show instead of NULL, but to be honest, I wouldn't know what to do with that handle even if I had it. Pretty much stumped with the limited knowledge I have.

Here is the portion of code that I believe is pertinent to my question. Let me know if you want to see anything else. Appreciate any advice you can provide! Thanks!

IFileSaveDialog* pSaveDialog;
...
...
DWORD dwOptions;
hr = pSaveDialog->GetOptions(&dwOptions);
pSaveDialog->SetOptions(dwOptions | FOS_OVERWRITEPROMPT | FOS_NOTESTFILECREATE | FOS_NOVALIDATE);

hr = pSaveDialog->Show(NULL);
if (SUCCEEDED(hr))
{
  // Grab the shell item that user specified in the save dialog
  IShellItem* pSaveResult = NULL;
  hr = pSaveDialog->GetResult(&pSaveResult);
  if (SUCCEEDED(hr))
  {
    // Extract the full system path from the shell item
    PWSTR pszPathName = NULL;
    hr = pSaveResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPathName);
  }
  if (SUCCEEDED(hr))
  {
    ...
    SetFileAttributes(CW2CT(pszPathName), FILE_ATTRIBUTE_NORMAL);
    ...
  }
}


problem on access SD memory card using DeviceIoControl

$
0
0

user-mode application could use DeviceIoControl() to send SD commands (cmd0, ... those defined in SD card physical specification) to SD memory card directly.

(Of couse this memory card must be plugged into NoteBook computer directly instead of employing a card reader).

For example, DeviceIoControl(hVol, IOCTL_SFFDISK_DEVICE_COMMAND, structure of SFFDISK_DEVICE_COMMAND_DATA, ...)

Here comes the problem:

In SFFDISK_DEVICE_COMMAND_DATA structure in sffdisk.h, one field "Command" of enumeration type SFFDISK_DCMD indicate "the kind of action" to be performed.

This field could be

SFFDISK_DC_GET_VERSION,
SFFDISK_DC_LOCK_CHANNEL,
SFFDISK_DC_UNLOCK_CHANNEL,
SFFDISK_DC_DEVICE_COMMAND

For the three former cases, DeviceIoControl() works correctly, but for the later one, it always fails with errorce 5 (access denied)

This user-mode application is run under "Administrator" logon session.

I tried to clear DACL of this SD card such that everyone has fully access to this memory card.

But DeviceIoControl() still terminates with ERROR_ACCESS_DENIED.

Accroding to MSDN cc500400,

Handle to Logical and Physical disk drives might be different.  I tried both cases but DeviceIoControl() still does not function.

Any one could help this ?

 

Viewing all 6180 articles
Browse latest View live