Skip to content

Instantly share code, notes, and snippets.

View pedroinfo's full-sized avatar

Pedro Xavier pedroinfo

  • São Paulo - BR - Solar System | Milky Way
View GitHub Profile
public static class ConfigurationHelper
{
public static IConfigurationRoot GetConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()) // Define o diretório base
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); // Carrega o arquivo JSON
return builder.Build();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage(); // Exibe erros detalhados em desenvolvimento
}
else
{
// Em produção, você pode optar por exibir detalhes de erro
app.UseExceptionHandler(errorApp =>
Function IsSmartCardCertificate(pCertContext As LongPtr) As Boolean
Dim cbData As Long
Dim provInfo As String
Dim isSmartCard As Boolean
' Obtém o tamanho das informações do provedor de chaves
If CertGetCertificateContextProperty(pCertContext, CERT_KEY_PROV_INFO_PROP_ID, 0, cbData) = 0 Then
IsSmartCardCertificate = False
Exit Function
End If
Option Explicit
' Windows API Declarations
Private Declare PtrSafe Function CertOpenSystemStore Lib "crypt32.dll" Alias "CertOpenSystemStoreA" (ByVal hProv As LongPtr, ByVal szSubsystemProtocol As String) As LongPtr
Private Declare PtrSafe Function CertFindCertificateInStore Lib "crypt32.dll" (ByVal hCertStore As LongPtr, ByVal dwCertEncodingType As Long, ByVal dwFindFlags As Long, ByVal dwFindType As Long, ByVal pvFindPara As LongPtr, ByVal pPrevCertContext As LongPtr) As LongPtr
Private Declare PtrSafe Function CertGetNameString Lib "crypt32.dll" Alias "CertGetNameStringA" (ByVal pCertContext As LongPtr, ByVal dwType As Long, ByVal dwFlags As Long, ByVal pvTypePara As LongPtr, ByVal pszNameString As String, ByVal cchNameString As Long) As Long
Private Declare PtrSafe Function CertGetCertificateContextProperty Lib "crypt32.dll" (ByVal pCertContext As LongPtr, ByVal dwPropId As Long, ByVal pvData As LongPtr, ByRef pcbData As Long) As Long
Private Declare PtrSafe Function CertCloseStore Lib "crypt32.dll" (ByV
Private Declare PtrSafe Function CertOpenStore Lib "Crypt32.dll" ( _
ByVal lpszStoreProvider As String, _
ByVal dwEncodingType As Long, _
ByVal hCryptProv As LongPtr, _
ByVal dwFlags As Long, _
ByVal pvPara As LongPtr) As LongPtr
Private Declare PtrSafe Function CertCloseStore Lib "Crypt32.dll" ( _
ByVal hCertStore As LongPtr, _
ByVal dwFlags As Long) As Long
@pedroinfo
pedroinfo / Regex.vba
Created February 25, 2025 14:07
Regex
digo VBA para Extrair o Conteúdo entre Parênteses
vba
Copiar
Editar
Function ExtrairConteudoParenteses(ByVal texto As String) As String
Dim regex As Object
Dim match As Object
Set regex = CreateObject("VBScript.RegExp")
Private Declare PtrSafe Function CertOpenStore Lib "Crypt32.dll" ( _
ByVal lpszStoreProvider As String, _
ByVal dwEncodingType As Long, _
ByVal hCryptProv As LongPtr, _
ByVal dwFlags As Long, _
ByVal pvPara As LongPtr) As LongPtr
Private Declare PtrSafe Function CertCloseStore Lib "Crypt32.dll" ( _
ByVal hCertStore As LongPtr, _
ByVal dwFlags As Long) As Long
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
public class Result<T>
{
public T Value { get; }
public string Error { get; }
public bool IsSuccess => Error == null;
private Result(T value, string error)
{
Value = value;
Error = error;
Sub RequisicaoWinHTTP()
' Cria o objeto WinHttpRequest
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
' URL de destino
Dim url As String
url = "https://jsonplaceholder.typicode.com/posts/1"
On Error GoTo ErroHandler