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

find() returns -1 when searching binary search tree

$
0
0

Hi,

I have two strings, one of which is named  "strIn". The other is a property on a "leaf" - for brevity, I'll call this one strOut except in my code.

I'm trying to see if strOut begins with strIn. That is, if strOut is "KAREN" and strIn is "KAR", then find() should return 0. However, it instead returns -1

Here is my code:

string bTreeClass::Search(string strIn)
{
	string strOut;

	// Binary trees are organized so that the lower leaf is on the left
	// Start with the root leaf(current leaf is the root leaf
	LeafClass *currentLeaf = rootLeaf;
	//	Loop until match found or current leaf has no links
	while (true)
	{
		int find = currentLeaf->GetString().find(strIn);
		//	If strIn is in currentLeaf's string
		if (currentLeaf->GetString().find(strIn) == 0)
			// Match found
			// Exit Loop
			break;
		//	 Else if search data is less than current leaf data
		else if (strIn.compare(currentLeaf->GetString()) < 0) {
			//	If current leaf does not have a left node
				if (currentLeaf->GetLeftLink() == nullptr)
					//	Match failed
					//	Exit loop
					break;
			//	Else current leaf does have a left node
				else
					//	Advance current leaf to current leaf's left node
					currentLeaf = currentLeaf->GetLeftLink();
				//	End if
			}
		// Else (search data is greater than current leaf data)
		else {
			//	If current leaf does not have a right node
			 if (currentLeaf->GetRightLink() == nullptr)
					//	Match failed
					//	Exit loop
					break;
				//	Else current leaf does have a right node
				else
					//	Advance current leaf to current leaf's right node
					currentLeaf = currentLeaf->GetRightLink();
				//	End if
			//	End if
			}
		//	End loop
		}
	strOut = currentLeaf->GetString();
	return strOut;
}



Issue in VB.Net converting datetaken attribute returned from GetDetailsOf method from string to datetime

$
0
0

I'm returning the datetaken attribute from the GetDetailsOf method from jpg files in a folder, but when I do a DateTime.parse conversion against the returned string I get an error saying: String was not recognized as a valid datetime. I displayed the string in a textbox and it is: 9/‎30/‎2016 ‏‎5:24 PM, which is obviously a valid datetime. I did a test by inserting that date as a literal in a test string and the conversion worked fine against the test string. Anybody had experience with datetime attributes returned as strings from getdetailsof method?

pertinent code snippets:

If String.Compare(Microsoft.VisualBasic.Right(fullfileName, 3), "jpg", True) = 0 Then
                        lastslashpos = fullfileName.LastIndexOf("\")
                        filename = fullfileName.Substring(lastslashpos + 1)
                        attrstring = GetAttributes(sourceDirectory, filename) ' Calling getdetailsof here
                        TextBox1.AppendText(vbNewLine & attrstring) 'Here's where I looked at the date taken returned, good datetime 
                        datetaken = DateTime.Parse(attrstring) 'FAILS HERE
                        datetakenlist.Add(New KeyValuePair(Of Date, String)(datetaken, filename))
                    End If

Function GetAttributes(GApath As String, GAfilename As String) As String
        Dim objShell As Object
        Dim objFolder As Object
        Dim attributes As String = ""
        objShell = CreateObject("Shell.Application")
        objFolder = objShell.Namespace(GApath.ToString)
         ' extended attribute 12 = Date Taken
        Attributes = (objFolder.GetDetailsOf(objFolder.ParseName(GAfilename), 12))
        Return attributes
    End Function

 

 

Stan Dodd

std::string::find() returns -1 when searching binary search tree

$
0
0

Hi,

I have two strings, one of which is named  "strIn". The other is a property on a "leaf" - for brevity, I'll call this one strOut except in my code.

I'm trying to see if strOut begins with strIn. That is, if strOut is "KAREN" and strIn is "KAR", then find() should return 0. However, it instead returns -1

Here is my code:

string bTreeClass::Search(string strIn)
{
	string strOut;

	// Binary trees are organized so that the lower leaf is on the left
	// Start with the root leaf(current leaf is the root leaf
	LeafClass *currentLeaf = rootLeaf;
	//	Loop until match found or current leaf has no links
	while (true)
	{
		int find = currentLeaf->GetString().find(strIn);
		//	If strIn is in currentLeaf's string
		if (currentLeaf->GetString().find(strIn) == 0)
			// Match found
			// Exit Loop
			break;
		//	 Else if search data is less than current leaf data
		else if (strIn.compare(currentLeaf->GetString()) < 0) {
			//	If current leaf does not have a left node
				if (currentLeaf->GetLeftLink() == nullptr)
					//	Match failed
					//	Exit loop
					break;
			//	Else current leaf does have a left node
				else
					//	Advance current leaf to current leaf's left node
					currentLeaf = currentLeaf->GetLeftLink();
				//	End if
			}
		// Else (search data is greater than current leaf data)
		else {
			//	If current leaf does not have a right node
			 if (currentLeaf->GetRightLink() == nullptr)
					//	Match failed
					//	Exit loop
					break;
				//	Else current leaf does have a right node
				else
					//	Advance current leaf to current leaf's right node
					currentLeaf = currentLeaf->GetRightLink();
				//	End if
			//	End if
			}
		//	End loop
		}
	strOut = currentLeaf->GetString();
	return strOut;
}



Using AlphaFS.dll for long paths...

$
0
0
I was just wondering how to use Alphafs.dll for long file paths/long directory paths or if anyone has used/is using AlphaFS.dll with VB.Net to copy a directory with a progressbar giving the progress of the current file that it's on and telling how many files it has processed from that directory. I have tried to just copy the files using the copy method within Alphafs.dll and all that does is just put one file inside of a folder, and then makes a new folder and puts one file inside of that folder. If anyone could give me an example as of how to use AlphaFS.dll using VB.Net to do so, it would be greatly appreciated. q;o)

Windows Server 2012 R2 CDC serial driver

$
0
0

Hi all,

Can i get any help on how to get the CDC serial driver for windows server 2012 r2.  When I connect my hardware to Windows 7/10, then the corresponding USB-Serial driver gets installed and my device is getting listed(COM37) under Ports of Device Manager.

But in windows server 2012 r2, it is getting detected as CDC serial in device manager, but the driver is not being installed. So the COM port is not being shown. Where can i get the CDC driver for windows server 2012, so that I can use it as COM port?

How can i proceed? Any suggestions.

Thanks.

Shwetha

How to allow standard user application to change IP Address of local machine under Windows 8

$
0
0

Hi All,

i'm working on a platform for which i would like standard user to change the IP Address of the device. From my C# application I'm using the WMI interface, requesting settings from Win32_NetworkAdapterConfiguration class, and this works like a charm when application runs with Administrator privileges (based on this project https://github.com/NitroAMD/IPv4NICSettingsTool).

For my system use case, the device auto logon as a lambda user with no rights and my app is launched (using the shell Launcher of WES 8). So this app doesn't have any Administrator privileges and this is a main problem when trying to access the network interface configuration. I don't want lambda user to enter any user accounts name or password to perform the network configuration.

So is their any GPO or system settings that could allows my application to perform those network configuration operations ?

Iterate app.config file to find values custom values

$
0
0

Hello,

I have added above keys in my app.Config files. I want to loop through these nodes to capture URL,FileName & Destination for each node.
Is there any easy way of doing this?

<MyNodes><MyNode><URL> https://MySite.com </Source-URL><FileName> Test.txt </query><Destination>C:\Temp\Test</Output-File></MyNode><MyNode><URL> https://MySite.com </Source-URL><FileName> Test1.txt </query><Destination>C:\Temp\Test1</Output-File></MyNode><MyNode><URL> https://MySite.com </Source-URL><FileName> Test2.txt </query><Destination>C:\Temp\Test2</Output-File></MyNode></NewsDownloads></MyNodes>

Does AllocationPreference Registry key still work in Windows 10 x64?

$
0
0

I'm testing a 32-bit VC++ application with LARGE_ADDRESS_AWARE turned on, and I want to test when memory is allocated top-down in the address space.  I set the Registry DWORD value AllocationPreference to 0x100000 as documented in MSDN.  (Full path is HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/Session Manager/Memory Management).  Allocations still happen bottom-up.  My C++ code is trivial:

   for (int i = 0; i < 96; i++) printf ("p=%p\n", malloc (1024 * 1024 * 32));

The output shows ascending addresses.  If I run the same program on Windows 7 x64, also with the Registry value set, then allocations happen top-down - descending addresses.

Is that Registry value no longer supported in Windows 10?


Initialize view context in fileDialog

$
0
0

Hi,

I am working onIFileOpenDialog/IFileDialog interfaces using MSDN example shown in

https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/winui/shell/appplatform/commonfiledialog

In the fileDialog there is an icon in upper right corner to choose

    View Context which contains ‘Extra Large Icon’, ‘Large Icon’, ‘Medium Icon’, etc.

I tried to make fileDialog openalways with‘Medium Icon’, for instance

I made two attemptsFirst attempt was below,

////////////////////////////////////////////55555
	 IExplorerBrowser *peb;
         hr = pfd->QueryInterface(IID_PPV_ARGS(&peb));
	 FOLDERSETTINGS *pfs;
	 pfs->ViewMode = (UINT)2;
	 pfs->fFlags = 0;
	 peb->SetFolderSettings(pfs);   ////////????????
	 peb->Release();
////////////////////////////////////////////////5555555

The second attempt was below

/////////////////////////////////////////////////6666666
	 IFolderView *pfv;
	 hr = pfd->QueryInterface(IID_PPV_ARGS(&pfv));
	 hr = pfv->SetCurrentViewMode(FVM_SMALLICON);  // FVM_TILE);///////??????
	 pfv->Release();
///////////////////////////////////////////////////666666

In both cases the code compiles and links OK.

But when I execute the code it stops at

 First case:

       peb->SetFolderSettings(pfs);   ////////????????

 Second case,

       hr = pfv->SetCurrentViewMode(FVM_SMALLICON); // FVM_TILE);///////??????

The complete code which includes these attemps is listed below.

I would appreciate your help as always, please

Thank you,

ChangChiTheGraphics

int cdir71(char *nameIn, int option){
	 char orig[100], origDef[100];
	 strcpy(orig, nameIn);
	 strcpy(origDef, "C:");
	 size_t origsize = strlen(orig) + 1;
	 size_t origDefsize = strlen(origDef) + 1;
	 size_t convertedChars = 0;
	 wchar_t wcstring[MAXPATH],wcstringDef[MAXPATH]; //newsize];

	 mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
	 mbstowcs_s(&convertedChars, wcstringDef, origDefsize, origDef, _TRUNCATE);
	 bPushbuttonUsed = FALSE;

// CoCreate the File Open Dialog object.
//IFileDialog *pfd = NULL;
	 IFileOpenDialog *pfd = NULL; // Need IFileOpenDialog to allow for multiple selections
	 HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
	 if (SUCCEEDED(hr)){
// Create an event handling object, and hook it up to the dialog.
		 IFileDialogEvents *pfde = NULL;
		 hr = CDialogEventHandler_CreateInstance(IID_PPV_ARGS(&pfde));
		 if (SUCCEEDED(hr)){
// Hook up the event handler.
			 DWORD dwCookie;
			 hr = pfd->Advise(pfde, &dwCookie);
			 // Set up a Customization.
			 IFileDialogCustomize *pfdc = NULL;
			 hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdc));

 // Create a Visual Group.
 hr = pfdc->StartVisualGroup(CONTROL_GROUPA, L"  ");
 // Add a radio-button list.
 hr = pfdc->AddPushButton(CONTROL_PUSHBUTTON, L"Select");
 hr = pfdc->AddPushButton(CONTROL_PUSHBUTTON1, L"Help");
 // Set the state of the added radio-button list.
 hr = pfdc->SetControlState(CONTROL_PUSHBUTTON, CDCS_VISIBLE | CDCS_ENABLED);
 hr = pfdc->SetControlState(CONTROL_PUSHBUTTON1, CDCS_VISIBLE | CDCS_ENABLED);
 // End the visual group.
 pfdc->EndVisualGroup();
 hr = pfdc->MakeProminent(CONTROL_PUSHBUTTON);
 pfdc->Release();
 IFileDialog *pfdd = NULL;
 hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdd));
 hr = pfdd->SetOkButtonLabel(L"Exit");
 pfdd->Release();
 if (SUCCEEDED(hr)){
// Set the options on the dialog.
 DWORD dwFlags;
// Before setting, always get the options first in order not to override existing options.
 hr = pfd->GetOptions(&dwFlags);
 if (SUCCEEDED(hr)){
// In this case, get shell items only for file system items.
// ADDED FOS_ALLOWMULTISELECT to allow for multiple selection
 hr = pfd->SetOptions(dwFlags | FOS_FORCEFILESYSTEM | FOS_ALLOWMULTISELECT);
// In this case, get shell items only for file system items.
// hr = pfd->SetOptions(dwFlags | FOS_FORCEFILESYSTEM);
 if (SUCCEEDED(hr)){
// Set the file types to display only. Notice that, this is a 1-based array.
 hr = pfd->SetFileTypes(ARRAYSIZE(c_rgSaveTypes), c_rgSaveTypes);
// Specify the starting folder for the dialog
 IShellItem *psif = NULL;
 HRESULT hr = SHCreateItemFromParsingName(wcstring, NULL, IID_PPV_ARGS(&psif));
 if (SUCCEEDED(hr)){
 hr = pfd->SetFolder(psif);
 psif->Release();
 }
 if (SUCCEEDED(hr)){
// Set the selected file type index to Word Docs for this example.
// hr = pfd->SetFileTypeIndex(INDEX_WORDDOC);
 hr = pfd->SetFileTypeIndex(INDEX_WEBPAGE);
// hr = pfd->SetFileTypeIndex(INDEX_TEXTDOC);
//////////////////////////////////////////////555555555
 IExplorerBrowser *peb;
 hr = pfd->QueryInterface(IID_PPV_ARGS(&peb));
 FOLDERSETTINGS *pfs;
 pfs->ViewMode = (UINT)2;
 pfs->fFlags = 0;
 peb->SetFolderSettings(pfs);   ////////????????
 peb->Release();
////////////////////////////////////////////////5555555
/////////////////////////////////////////////////6666666
 IFolderView *pfv;
 hr = pfd->QueryInterface(IID_PPV_ARGS(&pfv));
 hr = pfv->SetCurrentViewMode(FVM_SMALLICON);  // FVM_TILE);///////??????
 hr = pfv->SetCurrentViewMode((UINT) 2);  // FVM_TILE);
 pfv->Release();
/////////////////////////////////////////////////6666666
// Show the dialog
 hr = pfd->Show(NULL);
//Make the following change to call a new helper function(code for helper function is below) :
 if (SUCCEEDED(hr)){
// call helper function to display multiple selections
 (HRESULT)hr = DisplaySelections(pfd);
 if (SUCCEEDED(hr)){
// Set the default extension to be ".doc" file.
// hr = pfd->SetDefaultExtension(L"doc");
   hr = pfd->SetDefaultExtension(L"bmp");
// hr = pfd->SetDefaultExtension(L"*");
 }
 }
 }
 }
 }
 // Unhook the event handler.
 pfd->Unadvise(dwCookie);
 }
 pfde->Release();
 }
 pfd->Release();
 }
 if (cFileName != NULL){
   free(cFileName); cFileName = NULL;
 }
 if (cSelectedNames != NULL){
   free(cSelectedNames); cSelectedNames = NULL;
 }
 return (0);
}//int cdir71(char *nameIn, int option)




chang Chi

Controlling an interface pointer value

$
0
0

I need to have an interface pointer for IStream returned by SHCreateMemStream() which bytes do not contain 0x00 (don't ask why, just assume this as a fact). That is, there must be no 0x00AABBCC, 0xAA00BBCC, 0xAABB00CC or 0xAABBCC00 values returned.

How can I take control of it? When I release some pointer allocated previously which has zero byte, new allocation returns it to me again. I've found only one thing that influences it — e.g. showing File[Open/Save]Dialog with use of Co(Un)Initialize, which makes some memory reordiring, so the IStream pointer returned after that process have no 0x00 in the most significant byte. But of course it is not a solution when you need to occasionally create several interface pointers — that dialog mustn't be shown all times, or even it just not needed to be shown in time when pointers are allocated.


If I fall I will arise on my way to paradise

How to gain file name in Windows Explorer

$
0
0

Hi,

I work with the windows explorer using

ShellExecute(ViewWindow, "open", szFolder1, nullptr, nullptr, SW_SHOW);

I am wondering if it is possible:

When I click on a file like “abc.bmp”, for example, I like to get the name and path of that file.

Thank you for your help.

ChangChiTheGraphics


chang Chi

local share access using a particular hostname without username and password

$
0
0

Hi all,

     We want to access a share point created in localhost by a particular hostname which is not the same as the true hostname. For example, we want to access \\fileserver\sharepoint, where "sharepoint" is the local share point, but "fileserver" is not the true server name. so we set the windows host file and add a new line in the end:

127.0.0.1 fileserver

     However, when we access the share point by windows explore, a prompt for username and password is poped. But no matter what account and password is input, it always prompt that the password is not correct. when we use 127.0.0.1 or the true server name or localhost, we can access the share point directly without username and password input.

     We test this in Win7, win8 and win10. But it all need to input username and password.

     How can we access a local share point without a particular hostname name without username and password input?

     Thank you very much!



VB error with DirectX

$
0
0

Hi

Several years ago I wrote a Visual Basic program in Visual Studio Express 2008.  I used DirectX for sound playback and that worked just fine.  I have purchased a Windows 10 machine and tried to run that application on it and got numerous error messages.

I installed Visual Studio 2015 on it and loaded my code up on that new machine.  

I previously asked for some assistance in this thread and we were able to:

1)  Install the Windows 10 SDK

2)  Add the Reference to Microsoft.Visual.C

Since this is a new error, the moderator suggested asking the follow up question as a new post.

When the program is run in Debug mode and x86, I get two pop up with this error below.  If I click OK to each, the program will run.  

Managed Debugging Assistant 'LoaderLock' has detected a problem in 'path to my app.vshost.exe'.

Additional information: DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

I clearly need to resolve that error if I am going to be able to run it and compile it for use.  However, I'm a bit stumped, being a novice with VB with all the changes.

What the program does is read the input from a game pad controller, in this case a Microsoft XBOX Controller for Windows.  When a certain button is pressed, a random sound file is played from a specified folder for that button.


Paul http://paulsr2d2.blogspot.com http://www.youtube.com/paulsr2d2

C++ solution to block all mouse and keyboard input events for the entire OS, but still read input in my program

$
0
0

Hello Microsoft,

I am building a software KVM switch (to control multiple machines from a single machine mouse/keyboard, similar to ShareMouse, check it out if you're not familiar) and I ran into a brick wall let me explain:

My program needs to switch the control over network from the machine I am using(computer A) to the other machine(computer B) when the mouse cursor would exit from my desktop(computer A) and "magically" reappear on the other machine(computer B) while I am still using the computer A. In order for me to implement this feature, when the program reaches this state I need to be able to block all keyboard and mouse events from reaching to windows(except to my program) while at the same time be able to read all the keyboard/mouse events in my program(on computer A) so I can send them over network to computer B and dispatch them on that machine.

I found only one solution to block the input events using the C++ windows API exposed method BlockInput() which under Administrator rights works perfect, however when I globally block all the input, I can't read it in my program any more until I unblock it again:

"When input is blocked, real physical input from the mouse or keyboard will not affect the input queue's synchronous key state (reported by GetKeyState and GetKeyboardState), nor will it affect the asynchronous key state (reported by GetAsyncKeyState). However, the thread that is blocking input can affect both of these key states by calling SendInput. No other thread can do this." - quote from MSDN documentation

How could I block input events for all applications and operating system similar to BlockInput(), and still be able to read the mouse/keyboard events in my program? I am pretty sure this is possible because ShareMouse is doing it somehow.

Thanks in advance. I hope I was pretty clear in my request, if not I will try to elaborate more.

textmetrics.widthIncludingTrailingWhitespace computation for huge layoutWidth and centered text alignment

$
0
0

textmetrics.widthIncludingTrailingWhitespace computation is very imprecise at huge layoutWidth values for text alignment set to DWRITE_TEXT_ALIGNMENT_CENTERED. For example, we compute for a text width equal to 1586.44, and enter a value of 5E10 for layoutWidth. This gives us for widthIncludingTrailingWhitespace a value of 2048.

A more detailed research suggests that widthIncludingTrailingWhitespace most probably is computed as TextRect.right - TextRect.left, and this subtraction operation is prone to accumulating errors, because datatypes of a diminuend and a subtracted value are float, not double.

A huge layoutWidth value is used in a common technique for measuring text width, which includes a statement for creating text layout like this:

pDWriteFactory_->CreateTextLayout(
   wszText_,
   cTextLength_,
   pTextFormat_,
   FLOAT_MAX,
   1.0f,
   &pTextLayout_
  )

A developer must be careful not to assign accidentally a text alignment value other than LEADING (left) before text metrics measurement operation.

Is it worth to correct DirectWrite API to improve the widthIncludingTrailingWhitespace computation?

Code:

// DWriteConsoleApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#define HR(x) { HRESULT nValue = (x); if (FAILED(nValue)) return nValue;}

int PrintTextmetrics(DWRITE_TEXT_METRICS textmetrics)
{
 printf_s("   left: %g; top: %g\n   height: %g;        width: %g\n   widthIncludingTrailingWhitespace: %g\n   layoutWidth: %g; layoutHeight: %g\n   lineCount: %d; maxBidiReorderDepth %d\n\n",
  textmetrics.left, textmetrics.top,
  textmetrics.height, textmetrics.width, textmetrics.widthIncludingTrailingWhitespace,
  textmetrics.layoutWidth, textmetrics.layoutHeight,
  textmetrics.lineCount, textmetrics.maxBidiReorderingDepth);
 return 0;
}

int main()
{
 IDWriteFactory* pDWriteFactory_ = nullptr;
 IDWriteTextFormat* pTextFormat_ = nullptr;
 IDWriteTextLayout* pTextLayout_ = nullptr;
 IDWriteTextLayout1* pTextLayout1_ = nullptr;

 const wchar_t* wszText_;
 UINT32 cTextLength_;
 float layoutWidth = 5E10f;
 float layoutHeight = 200.f;
 int nScanf = 0;
 HRESULT hr = S_OK;
 do
 {
  printf_s("Layout Width ('-1' exits program, '0' defaults layoutWidth to 5E10):");
  nScanf = scanf_s("%f", &layoutWidth);
  if (layoutWidth < 0) return 0;
  if (layoutWidth == 0)
   layoutWidth = 5E10f;
  HR(DWriteCreateFactory(
   DWRITE_FACTORY_TYPE_SHARED,
   __uuidof(IDWriteFactory),
   reinterpret_cast<IUnknown**>(&pDWriteFactory_)
  ));
  HR(pDWriteFactory_->CreateTextFormat(
   L"Gabriola",
   NULL,
   DWRITE_FONT_WEIGHT_REGULAR,
   DWRITE_FONT_STYLE_NORMAL,
   DWRITE_FONT_STRETCH_NORMAL,
   64.0f,
   L"en-us",
   &pTextFormat_
  ));
  wszText_ = L"Hello World using DirectWrite! And so on, to show us how text wraps in this app. ";
  cTextLength_ = (UINT32)wcslen(wszText_);
  HR(pDWriteFactory_->CreateTextLayout(
   wszText_,
   cTextLength_,
   pTextFormat_,
   layoutWidth,
   layoutHeight,
   &pTextLayout_
  ));
  HR(pTextLayout_->QueryInterface(__uuidof(IDWriteTextLayout1), reinterpret_cast<void**>(&pTextLayout1_)));
  DWRITE_TEXT_RANGE textRange = { 0, cTextLength_ };
  HR(pTextLayout_->SetFontSize(64.0f, textRange));
  HR(pTextLayout_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING)); // LEFT
  DWRITE_TEXT_METRICS textmetrics;
  HR(pTextLayout_->GetMetrics(&textmetrics));
  printf_s("LEADING (Left) ALIGNED:\n");
  PrintTextmetrics(textmetrics);
  
  HR(pTextLayout_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER)); // CENTER
  HR(pTextLayout_->GetMetrics(&textmetrics));
  printf_s("CENTERED (Center) ALIGNED:\n");
  PrintTextmetrics(textmetrics);
  
  HR(pTextLayout_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING)); // RIGHT
  HR(pTextLayout_->GetMetrics(&textmetrics));
  printf_s("TRAILING (Right) ALIGNED:\n");
  PrintTextmetrics(textmetrics);
  
  HR(pTextLayout_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_JUSTIFIED)); // JUSTIFIED
  HR(pTextLayout_->GetMetrics(&textmetrics));
  printf_s("JUSTIFIEDSPACE ALIGNED:\n");
  PrintTextmetrics(textmetrics);
 } while (layoutWidth >= 0);
 return 0;
}


DlgDirList fails to find files if "File is ready for archiving" attribute is not set

$
0
0
We call DlgDirList to obtain a list of files in a folder. We have found that if the user right-clicks the file and chooses "Advanced" attributes and then unchecks "File is ready for archiving", DlgDirList fails to return the file. I have tried setting all the file type bits and even 0xfffffff and then most of the individual bits (DDL_ARCHIVE, DDL_READ, DDL_READWRITE ...) but still the file doesn't show up when I get the count and enumerate the entries. Why does a missing FILE_ATTRIBUTE_ARCHIVE bit on the file cause this problem? And how can I get DlgDirList to detect files that don't have that attribute?

R.D. Holland

USER32 & SHELL32.

$
0
0
I’m trying to find a list of commands that are available under USER32 & SHELL32. Can anyone help me?

COM Runtime Breakdown in Multithreaded Server Application

$
0
0
We are experiencing intermittent catastrophic failures of the COM runtime in a large server application.

Here's what we have:

A server process running as a Windows service hosts numerous free-threaded COM components written in C++/ATL. Multiple client processes written in C++/MFC and .NET use these components via cross-procces COM calls (incl .NET interop) on the same machine. The OS is Windows Server 2008 R2 Terminal Server.
The entire software suite was developed in-house, we have the source code for all components. A tracing toolkit writes out errors and exceptions generated during operation.

What is happening:

After some random period of smooth sailing (5 days to 3 weeks) the server's COM runtime appears to fall apart with any combination of these symptoms:

- RPC_E_INVALID_HEADER (0x80010111) - "OLE received a packet with an invalid header" returned to the caller on cross-process calls to server component methods
- Calls to CoCreateInstance (CCI) fail for the CLSCTX_LOCAL_SERVER context
- CoInitializeEx(COINIT_MULTITHREADED) calls fail with CO_E_INIT_TLS (0x80004006)

- All in-process COM activity continues to run, CCI works for CLSCTX_INPROC_SERVER.
- The overall system remains responsive, SQL Server works, no signs of problems outside of our service process.
- System resources are OK, no memory leaks, no abnormal CPU usage, no thrashing

The only remedy is to restart the broken service.

Other (related) observations:

- The number of cores on the CPU has an adverse effect - a six core Xeon box fails on 5 day intervals, smaller boxes take 3 weeks or longer.
- .NET Interop might be involved, as running a lot of calls accross interop from .NET clients to unmanaged COM server components also adversely affects the system.
- Switching on the tracing code inside the server process prolongs the working period.

Tracing does introduce some partial synchronization and thus can hide multithreaded race condition effects. On the contrary, running on more cores with hyperthreading runs more threads in parallel and increases the failure rate.

Has anybody experienced similar behaviour or even actually come accross the RPC_E_INVALID_HEADER HRESULT? There is virtually no useful information to be found on that specific error and its potential causes.
Are there ways to peek inside the COM Runtime to obtain more useful information about COM's private resource pool usage like memory, handles, synchronization primitives? Can a process' TLS slot status be monitored (CO_E_INIT_TLS)?

Application window screen capture has blank output

$
0
0
I am trying to screen capture an application window's contents, similar to the Alt-PrintScreen keyboard shortcut.

For most application windows, it works fine. However, for some applications, the result has blank output.

Relevant code:
const int height = 1000;
const int width = 1000;

const wchar_t *windowTitle = L"MEmu 2.8.6 - MEmu";
HWND hwndSrc = FindWindowEx(0, 0, 0, windowTitle);
HDC hdcSrc = GetWindowDC(hwndSrc);


PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
BitBlt(hdc, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);
EndPaint(hWnd, &ps);


Expected output:
i.imgur.com/23bcC0Z.png

Actual output:
i.imgur.com/chYb9g2.png


Why is it not working for some windows?

A Screensaver that Display a Website

$
0
0

Hi all, please provide assistance if you are able to.

1)How to create a screensaver that display a website?  I am open to free software to create a .scr file.

2)All our users do not sign on to a domain network so not able to use group policy to deploy to all machines.  How to force 2000 machines in different parts of the island to deploy the screensaver that display website without manual involvement?  How to force all machines to display this newly created screensaver?

I appreciate any assistance you can provide.  Thank you.

Viewing all 6180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>