what is it error function ? How can i call it . in what kind of library placed it ? i meet with this function and i do not know nothing about her .
e.g : error("I think") .
what is it error function ? How can i call it . in what kind of library placed it ? i meet with this function and i do not know nothing about her .
e.g : error("I think") .
Hello Folks:
Developing on Windows 10, C++.
Do Windows libraries still use HINSTANCE, or is that parameter just a relic for compatibility from the times when Windows was a wrapping for DOS.
When a function I'm using requires it, I'll often just grab it with a call to GetWindowLongPtr(). Right now I need HINSTANCE in a function wasn't passed a handle to a window.
An obvious solution is to pass an HINSTANCE globally, but I've always been adverse to using global variables.
If Windows still uses HINSTANCE, is there some way of acquiring it inside a function doesn't know about a particular window?
Thanks
Larry
I had created a sample Qt application (Main window) in Visual Studio 2015 comm. edn. And i get this error:
1>------ Rebuild All started: Project: Test2, Configuration: Debug Win32 ------
1> Moc'ing test2.h...
1> The filename, directory name, or volume label syntax is incorrect.
1> Uic'ing test2.ui...
1> The filename, directory name, or volume label syntax is incorrect.
1> Rcc'ing test2.qrc...
1> The filename, directory name, or volume label syntax is incorrect.
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 123.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Could someone please help me here. Thanks in advance.
Hello All,
In the template function we are using "explicit" keyword. I wanted to know why to use "explicit" keyword with template.
Below is the code snippet:
RegistryValue.h file
enum RegistryValueKindBecause, from the other .cpp file when i am trying to insert a vector into the SetValue function I am getting the below error:
no suitable user-defined conversion from "std::vector<std::wstring,std::allocator<std::wstring>>" to "const RegistryValue" exists.Thanks in Advance,
The code below builds without a problem with the following linker options: /ENTRY =main, /SUBSYSTEM = Not set in the project property page.
.386 .MODEL flat, stdcall .stack 4096 ExitProcess PROTO STDCALL, dwExitCode: DWORD .CODE main PROC mov eax, -1 invoke ExitProcess, 0 main ENDP END
But when I try to build the similar code below, just replacing main byWinMain, and the linker options /ENTRY = WinMain and /SUBSYSTEM = Not set, the linker complains with the error "LNK1221: a subsystem can't be inferred and must be defined".
.386 .MODEL flat, stdcall .stack 4096 ExitProcess PROTO STDCALL, dwExitCode: DWORD .CODE WinMain PROC mov eax, -1 invoke ExitProcess, 0 WinMain ENDP END
Hi.
I Decide to integrate WebCam (IMFSourceReaderCallback) to my engine and I make some workaround with MFCaptureD3D from Windows Sample. But I get a little confuse about two thing.
1. In my engine, all was synchronize, with CRXMaterial::OnTick. By Example, if you take IMFMediaEngine and ask to read a video (mp4/avi). This one get Texture ID3D11Texture2D1 from ID3D11ShaderResourceView1 and send it back to IMFMediaEngine::TransferFrame and your video frame was copy inside your texture.
Now with IMFSourceReaderCallback you must draw the frame inside IMFSourceReaderCallback::OnReadSample. If i will respect OnTick philosophy I got a idea. Buffering IMFMediaBuffer inside IMFSourceReaderCallback::OnReadSample and take it back inside CRXMaterial::OnTick to transfer inside resource texture.
2. The problem come with example who use IDirect3DSurface9 and YUV color system. In sort, how transfer IMF2DBuffer to ID3D11Texture2D?
OnReadSample
//*************************************************************************** //* Class name : CRXWebCam //* Output : HRESULT //* Function name : OnReadSample //* Description : //* Input : HRESULT hrStatus //* DWORD dwStreamIndex //* DWORD dwStreamFlags //* LONGLONG llTimestamp //* IMFSample* pSample //*************************************************************************** HRESULT CRXWebCam::OnReadSample(HRESULT hrStatus, DWORD dwStreamIndex, DWORD dwStreamFlags, LONGLONG llTimestamp, IMFSample* pSample) { HRESULT hr = S_OK; IMFMediaBuffer* pBuffer = NULL; if (FAILED(hrStatus)) hr = hrStatus; if (SUCCEEDED(hr)) { if (pSample) { hr = pSample->GetBufferByIndex(0, &pBuffer); //Buffering the frame m_pBuffer = pBuffer; m_pBuffer->AddRef(); // Draw the frame. } } if (SUCCEEDED(hr)) hr = m_pReader->ReadSample((DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, NULL, NULL, NULL); if (pBuffer) pBuffer->Release(); pBuffer = NULL; return hr; }
OnTick
//*************************************************************************** // Class name : CRXMedia // Function name : Render // Description : Render Media Class //*************************************************************************** void CRXMaterial::OnTick() { /*IDXGIFactory4* spFactory; IDXGIAdapter1* spAdapter; IDXGIOutput* spOutput; ThrowIfFailed(CreateDXGIFactory2(0, __uuidof(IDXGIFactory4), (void**)&spFactory)); ThrowIfFailed(spFactory->EnumAdapters1(0, &spAdapter)); ThrowIfFailed(spAdapter->EnumOutputs(0, &spOutput));*/ if (m_pMediaEngine) { if (/*SUCCEEDED(spOutput->WaitForVBlank()) && this && */!m_pMediaEngine->m_spMediaEngine->IsPaused()) { ID3D11Texture2D1* Texture; m_pTextureView->GetResource((ID3D11Resource**)&Texture); DWORD SizeX; DWORD SizeY; m_pMediaEngine->m_spMediaEngine->GetNativeVideoSize(&SizeX, &SizeY); RECT Rect = { 0,0, (LONG)SizeX, (LONG)SizeY }; MFVideoNormalizedRect NormRect = { 0.0f, 0.0f, 1.0f, 1.0f }; MFARGB BackColor = { 0, 0, 0, 255 }; m_pMediaEngine->TransferFrame(Texture, NormRect, Rect, BackColor); Texture->Release(); } } if (m_pWebCamEngine) //HERE { if (m_pWebCamEngine->m_pBuffer) { ID3D11Texture2D1* Texture; m_pTextureView->GetResource((ID3D11Resource**)&Texture); IMF2DBuffer* m_p2DBuffer = NULL; //m_pWebCamEngine->m_pBuffer->QueryInterface(IID_PPV_ARGS(&m_p2DBuffer)); m_pWebCamEngine->m_pBuffer->QueryInterface(IID_IMF2DBuffer, (void**)&m_p2DBuffer); BYTE* ppbScanLine0; LONG plStride; m_p2DBuffer->Lock2D(&ppbScanLine0, &plStride); //YUV to RGB??? /*for (DWORD y = 0; y < m_Height; y++) { RGBQUAD* pDestPel = (RGBQUAD*)mapped.pData; WORD* pSrcPel = (WORD*)ppbScanLine0; for (DWORD x = 0; x < 640; x += 2) { // Byte order is U0 Y0 V0 Y1 int y0 = (int)LOBYTE(pSrcPel[x]); int u0 = (int)HIBYTE(pSrcPel[x]); int y1 = (int)LOBYTE(pSrcPel[x + 1]); int v0 = (int)HIBYTE(pSrcPel[x + 1]); pDestPel[x] = ConvertYCrCbToRGB(y0, v0, u0); pDestPel[x + 1] = ConvertYCrCbToRGB(y1, v0, u0); } ppbScanLine0 += plStride; //mapped.pData += mapped.RowPitch; }*/ //m_pDirect3D->GetD3DDeviceContext()->Unmap(Texture, NULL); m_p2DBuffer->Unlock2D(); m_p2DBuffer->Release(); Texture->Release(); if (m_pWebCamEngine->m_pBuffer) m_pWebCamEngine->m_pBuffer->Release(); m_pWebCamEngine->m_pBuffer = NULL; } } /*spFactory->Release(); spAdapter->Release(); spOutput->Release();*/ }
Hello All,
I am trying to interface my VB6 with a DLL written in C++. The DLL was actually written by someone else here at the company who I do not have access to at the moment.
The function that I need to call is declared as follows:
//int a35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key);Where #define VBDLLFUNC(TypeName) DLLEXPORT TypeName __stdcall
The question that I have is this, what would the declare look like in VB6?
What is the equivalent to unsigned char*?
Please advise
Thank you
Gary
Hello,
What is the differences between Sizeof vs Length vs Capacity in C++?
In the below example:
Length() is 12.
Sizeof() is 28 and capacity is 15.
#include <iostream> #include<string> using namespace std; int main() { string s; getline(cin, s); int sl = s.length(); int so = sizeof(s); char* p = new char[sl]; for (int i = 0; i < sl; i++) { p[i] = s[i]; } for (int i = 0; i < sl; i++) { cout << p[i] << " "; } return 0; }
Hello All,
I am reading the below path
C:\ProgramData\EMR\Registration\RegistrationSubset.xml using strFilePath
parameter in the below ReadJsonFile function.
Now, my new requirement is, the same function should process array of paths and then loop through the array of path locations to find and read the available file path.
below is the array of paths. These paths are reading from .json file.
%programdata%\EMR\Registration\Registration_Subset.xml C:\ProgramData\EMR\Registration\RegistrationSubset.xml
%AppData%\EMR\EMR Setup\REGDATA\registration_subset.xml %AppData%\EMR\EMR Setup\REGDATA\RegistrationSubset.xml
Please help me how to read array of paths to find the available file path in the below function? And also how to resolve the path (i.e, while reading the path %programdata%\EMR how to change it to C:\programdata\EMR)?
Below is the code snippet:
bool EMRFileReader::ReadJsonFile(const std::wstring &strFilePath, std::wstring &strFileContent)
{
DWORD dwFileAttribute = FILE_ATTRIBUTE_NORMAL;
std::wstring strExtension = ::PathFindExtension(strFilePath.c_str());
if (strExtension.find(BLOB) != std::string::npos)
{
dwFileAttribute = FILE_ATTRIBUTE_ENCRYPTED;
}
HANDLE hFile = NULL;
LPBYTE lpData
= NULL;
hFile = CreateFile(strFilePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, dwFileAttribute, NULL);
if (INVALID_HANDLE_VALUE == hFile)
{
return false;
}
DWORD dwBytesReadWrite = 0, dwFileSize;
dwFileSize = GetFileSize(hFile, NULL);
lpData = new(nothrow) BYTE[dwFileSize];
if (lpData)
{
ReadFile(hFile, (LPVOID)lpData, dwFileSize, &dwBytesReadWrite, NULL);
}
CloseHandle(hFile);
if (dwBytesReadWrite > 0)
{
wstring strBase64;
string strData = string((char*)lpData);
EncodeBase64(dwBytesReadWrite, strData, strBase64);
strFileContent = strBase64;
}
if (lpData != NULL)
{
delete[] lpData;
}
return true;
}
Thank you,
How can I use windows API to enumerate foreground application in the task manager?
For example,if i open Edge & task manager.When I run my program, it will list Edge & task manager, not include background process .
"Exception Settings -> Win32 Exception" need to check above.
Run the sample code on .exe for the first time, Microsoft Visual Studio will thrown a exception "RPC_S_SERVER_UNAVAILABLE(0x000006BA)",but can continue to next step.
Does anyone one have the same problem ?
I dont know how to modify code. I look forward to your help.
The C++ sample code is as following:
CString csPrinterName = L"OneNote"; //printer name
std::unique_ptr<DEVMODE> pDevMode;
HANDLE hPrinter = NULL;
LPWSTR lpWstr = csPrinterName.GetBuffer(csPrinterName.GetLength());
if (::OpenPrinter(lpWstr, &hPrinter, NULL))
{
long lnSize = ::DocumentProperties(NULL, hPrinter, lpWstr, NULL, NULL, 0); //thorwn RPC_S_SERVER_UNAVAILABLE(0x000006BA),but can continue to run
if (lnSize > 0)
{
pDevMode.reset((DEVMODE*)new BYTE[lnSize]());
if (pDevMode)
{
pDevMode->dmSize = (unsigned short)lnSize;
lnSize = ::DocumentProperties(NULL, hPrinter, lpWstr, pDevMode.get(), NULL, DM_OUT_BUFFER);
if (lnSize != IDOK)
{
pDevMode.reset();
}
}
}
::ClosePrinter(hPrinter);
}
csPrinterName.ReleaseBuffer();
Recently, I have worked on Windows nvme drivers. After reading “Working with NVMe drives” at MSDN
I know how to send pass through vendor specific cmd to device. But what I want to know is how to send admin cmds and nvm cmds (such as read write) by windows api.
Can you give me some reference examples.
Thanks!
Only recently moved to VS2019 (using toolset v142)on W10 from VS2010 on W7. Compiles & runs ok in W10 but executable won't start in W7. Have checked dependencies & all dlls accounted for - are there any gotchas in doing this port that I may have overlooked?
Error reads, "The application was unable to start correctly (0x000007b). Click OK to close the application."
Hi, I am trying to configure Visual Studio 2017 to remotely build a C++ project using CMake on a Linux machine. The build must use the Red Hat SCL compiler collection, not the default gcc compiler on the machine.
I have specified a prebuild command in CMakeSettings.json:
"remotePrebuildCommand": "source scl_source enable devtoolset-7"
I'm not sure that that will force the scl to be used. I guess the correct headers won't be downloaded to the local machine for Intellisense's used.
A similar question was asked here:
The answer given was to specify the compiler in the Configuration Properties -> C/C++ -> General. But, is that only
for a Visual Studio Project? i.e. not for a CMake project?
How would I specify the compiler for a CMake project?
Hi,
Using Visual Studio 2017, I have a C++ Linux project which currently connects to a remote Linux machine (CentOS 7)
I have both GCC 4.8.5 and GCC 7.2.1 installed on the CentOS machine
How can I instruct Visual Studio to use the GCC 7.2.1? Currently it always defaults to 4.8.5.
I have tried adding the following to the Remote Pre-Build Event:
source scl_source enable devtoolset-7
scl enable devtoolset-7 bash
export CC=/opt/rh/devtoolset-7/root/usr/bin/gcc
export CXX=/opt/rh/devtoolset-7/root/usr/bin/cpp
export CPP=/opt/rh/devtoolset-7/root/usr/bin/c++
But no matter what I try the project always builds using GCC 4.8.5.
If I log on to the Linux machine, terminal window and type "scl enable devtoolset-7 bash" followed by "gcc --version" I get "gcc (GCC) 7.2.1 20170829 (Red Hat 7.2.1-1)"
Hello,
We cannot run the below code in Visual Studio and I have an error but in othercompilerit can be compile.
What's the difference?
#include<iostream> int main() { int n; cin>>n; int a[n]; return 0 ; }
I want to develop a C++ dynamic library, a DLL. It targets x64. But when the application that uses this DLL runs, I want the DLL to be loaded within range of signed 32 bit integer memory space.
How to do that?