Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • CFileDialog in CPropertySheet

    com help question
    4
    0 Votes
    4 Posts
    0 Views
    M
    Hi, Is this answer still valid while using Visual Studio 2019 ? The id IDD_FILEOPEN_EX does not exists. Do I need to include another RC file if I include dlgs.h ? Thanks. I'd rather be phishing!
  • WritePrinter Fails to Print on Inkjet Printer

    help csharp visual-studio question
    11
    0 Votes
    11 Posts
    0 Views
    S
    Noted. Thanks. Sandford
  • 0 Votes
    4 Posts
    2 Views
    V
    :)
  • 0 Votes
    6 Posts
    0 Views
    A
    I'm hoping to be able to use the function like this: queueTaskCpp([](uint8_t* data, uint16_t dataSizeBytes) { // My function implementation in PURE C (no C++) goes here... }, NULL, 0); I would assume the above function implementation would become static, right? God forbid if the function gets implemented on the stack, obviously that would mean I can't use this concept at all since the function implementation on the stack will most likely be corrupt when it's time to execute the queued function. I'm not planning to use any classes or object orientedness, I'm only using C++ to be able to pass anonymous functions like this.
  • Why isn't the copy constructor called

    question
    10
    0 Votes
    10 Posts
    0 Views
    Greg UtasG
    Yes. I'm very unimpressed by the spec but still impressed that the compiler bothered to implement this "optimization". Robust Services Core | Software Techniques for Lemmings | Articles The fox knows many things, but the hedgehog knows one big thing.
  • compilers for pure assembly code

    csharp visual-studio question
    5
    0 Votes
    5 Posts
    0 Views
    C
    What`s sets them apart from each other? Will they produce binary for everything that runs on AMD/Intel processors (taken that you link to the appropriate libraries)? Are there standards that ASM code needs to meet to run on any specific OS?
  • Embedded C program

    hardware
    6
    0 Votes
    6 Posts
    1 Views
    D
    Asking questions is a skill[^]. Seriously, if you want help from people, read that article. Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
  • 0 Votes
    5 Posts
    1 Views
    M
    Hi Claude, The reason of the problem is that the code uses the definition of MultiMon.h for function MonitorFromRect instead of using the native definition of this function coming from WinUser.h. Solution : remove line "include MultiMon.h" from OXToolTipCtrl.cpp to force the usage of WinUser.h definition for this function. Florianne :)
  • 0 Votes
    11 Posts
    0 Views
    S
    Note that C arrays do not include length information! So unless your function Function(uint8_t*) somehow knows how many elements there are, you'd also have to pass the number of elements as a separate parameter! And even if it does know how many elements to expect, there's always a chance someone calls it accidentally with a different number of elements. The class std::vector behaves like an array, but internally it does store the array length which makes the code examples above feasible. You could of course write a C++ wrapper that calls a C function internally, like this: void Function(uint8_t* values, unsigned long int size); //normal C function implemented elsewhere void Function(const std::vector& values) { Function(values.data(), values.size()); } int main() { Function({1, 2, 3}); return 0; } Otherwise, you'd have to think of another way to pass the element number reliably. GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
  • 0 Votes
    2 Posts
    0 Views
    L
    You need to add the following line to myDummyFile.cpp: #include "myDummyFile.h" Otherwise the compiler will generate a decorated* name for myDummyFunction, because the source file is C++ not C. *In C++ external names have additional characters so the linker will not match what is called from your main file.
  • Icons for Executable Files - SOLVED

    question linux
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • CWinThread for background processing

    design question announcement
    7
    0 Votes
    7 Posts
    0 Views
    CPalliniC
    Wow! :thumbsup:
  • 0 Votes
    29 Posts
    0 Views
    V
    :)
  • Microsoft Media Foundation AAC Decoder using C++

    question c++
    3
    0 Votes
    3 Posts
    3 Views
    1
    Some useful Media Foundation resources: Windows-classic-samples, Media Foundation. GitHub[^] Samples from Media Foundation Team Blog[^] Developing Microsoft Media Foundation Applications (Developer Reference)[^] This book contains the sample code available for downloading. Tanta, Windows Media Foundation Sample Projects[^] Hopefully, you will find something similar to your task.
  • Group policy editor api

    wpf windows-admin json help workspace
    7
    0 Votes
    7 Posts
    1 Views
    L
    Hi, You should add more error handling, this is just a code sample: #include #include #include #include #include #include #include #include #pragma comment(lib,"gpedit.lib") int main() { HKEY key; HKEY pol; DWORD val = 1; DWORD disp = 0; GUID ext = REGISTRY_EXTENSION_GUID; CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED); CComPtr lgp; HRESULT hr = CoCreateInstance(CLSID\_GroupPolicyObject, NULL, CLSCTX\_INPROC\_SERVER, IID\_IGroupPolicyObject, (LPVOID\*)&lgp); if (SUCCEEDED(lgp->OpenLocalMachineGPO(GPO\_OPEN\_LOAD\_REGISTRY))) { if (SUCCEEDED(lgp->GetRegistryKey(GPO\_SECTION\_MACHINE, &key))) { //All Removable Storage classes: Deny All access RegCreateKeyExW(key, L"SOFTWARE\\\\Policies\\\\Microsoft\\\\Windows\\\\RemovableStorageDevices", 0, NULL, REG\_OPTION\_NON\_VOLATILE, KEY\_WRITE | KEY\_QUERY\_VALUE, NULL, &pol, &disp); RegSetValueEx(pol, L"Deny\_All", 0, REG\_DWORD, (BYTE\*)&val, sizeof(val)); RegCreateKeyExW(key, L"SOFTWARE\\\\Policies\\\\Microsoft\\\\Windows\\\\RemovableStorageDevices\\\\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}", 0, NULL, REG\_OPTION\_NON\_VOLATILE, KEY\_WRITE | KEY\_QUERY\_VALUE, NULL, &pol, &disp); //Removable Disks: Deny write access RegSetValueEx(pol, L"Deny\_Write", 0, REG\_DWORD, (BYTE\*)&val, sizeof(val)); //Removable Disks: Deny read access RegSetValueEx(pol, L"Deny\_Read", 0, REG\_DWORD, (BYTE\*)&val, sizeof(val)); //Removable Disks: Deny execute access RegSetValueEx(pol, L"Deny\_Execute", 0, REG\_DWORD, (BYTE\*)&val, sizeof(val)); RegCloseKey(key); hr = lgp->Save(TRUE, TRUE, &ext, const\_cast(&CLSID\_GPESnapIn)); \_com\_error err(hr); wprintf(L"%s", err.ErrorMessage()); } } lgp.Release(); CoUninitialize(); return 0; } It will set the following policies: - All Removable Storage classes: Deny All access - Removable Disks: Deny execute access - Removable Disks: Deny read access - Removable Disks: Deny write access Best Wishes, -David Delaune [Edit two days later] You can also add an attack surface reduction policy via Windows Defender that requires anything that executes from USB to be signed: powershell.exe Add-MpPreference -AttackSurfaceReductionRules_Ids b2b3f03d-6a65-4f7b-a9c7-1c7ef74a9ba4 -AttackSurfaceReductionRules_Actions Enabled
  • 0 Votes
    7 Posts
    0 Views
    S
    When using already existing container types from the STL, just use the container type as template parameter. You can retrieve the element type with the internal type definition value_type like this: template istream& operator>>(istream& my_istream, Container& v) { typedef typename Container::value_type T; // now you can use T for your element type ... If you define your own container type, you can do it in the same way. You just have to make sure your container type does define value_type: template class MyContainer { public: typedef Element value_type; ... P.S.: IIRC STL containers already do have overrides for operator>>. You could save yourself some effort by just overriding this operator for your base type: template istream& operator>>(istream& my_istream, T& value) { ... It should work just as well as the above solution. P.P.S.: As it turns out I was wrong. There are no default implementations of operator>> for containers. GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
  • 0 Votes
    6 Posts
    0 Views
    L
    Works fine after fixing the missing semi-colon.
  • Programming.. Backtracking.

    help question
    5
    0 Votes
    5 Posts
    0 Views
    P
    vafoqome wrote: I need help with backtracking question. Helping you is not solving the problem for you. Show your work so far, and explain problem you encounter. Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • Easy and Quick Methods to Setup the Printer

    com help tutorial workspace
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • <pre>Ultimate Guidelines To Fix Error 1962 Lenovo

    help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied